Skip to content

Commit 062cb99

Browse files
committed
Merge pull request jpadilla#58 from wbolster/issue-57
Avoid ResourceWarning in tests
2 parents ab7fb28 + c725a47 commit 062cb99

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/test_jwt.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ def test_decodes_valid_jwt(self):
108108
@unittest.skipIf(not has_crypto, "Can't run without cryptography library")
109109
def test_decodes_valid_es384_jwt(self):
110110
example_payload = {'hello': 'world'}
111-
example_pubkey = open('tests/testkey_ec.pub', 'r').read()
111+
with open('tests/testkey_ec.pub', 'r') as fp:
112+
example_pubkey = fp.read()
112113
example_jwt = (
113114
b'eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9'
114115
b'.eyJoZWxsbyI6IndvcmxkIn0'
@@ -128,7 +129,8 @@ def test_decodes_valid_es384_jwt(self):
128129
@unittest.skipIf(not has_crypto, "Can't run without cryptography library")
129130
def test_decodes_valid_rs384_jwt(self):
130131
example_payload = {'hello': 'world'}
131-
example_pubkey = open('tests/testkey_rsa.pub', 'r').read()
132+
with open('tests/testkey_rsa.pub', 'r') as fp:
133+
example_pubkey = fp.read()
132134
example_jwt = (
133135
b'eyJhbGciOiJSUzM4NCIsInR5cCI6IkpXVCJ9'
134136
b'.eyJoZWxsbyI6IndvcmxkIn0'

0 commit comments

Comments
 (0)