Skip to content

Commit d052c3b

Browse files
committed
Wrap all the operations in try block
1 parent ce73b91 commit d052c3b

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

tests/conftest.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,19 @@ def access_token():
180180

181181
@pytest.fixture
182182
def fake_key_file(tmp_path_factory):
183-
tmp_path_factory._basetemp = Path().home()
184-
key_path = tmp_path_factory.mktemp(".sfapi_test1", numbered=False) / "key.pem"
185-
186-
# Make a fake key for testing
187-
key_path.write_text(
188-
f"""abcdefghijlmo
189-
-----BEGIN RSA PRIVATE KEY-----
190-
{rsa.generate_private_key(public_exponent=65537, key_size=2048)}
191-
-----END RSA PRIVATE KEY-----
192-
"""
193-
)
194-
key_path.chmod(0o100600)
195183
try:
184+
tmp_path_factory._basetemp = Path().home()
185+
key_path = tmp_path_factory.mktemp(".sfapi_test1", numbered=False) / "key.pem"
186+
187+
# Make a fake key for testing
188+
key_path.write_text(
189+
f"""abcdefghijlmo
190+
-----BEGIN RSA PRIVATE KEY-----
191+
{rsa.generate_private_key(public_exponent=65537, key_size=2048)}
192+
-----END RSA PRIVATE KEY-----
193+
"""
194+
)
195+
key_path.chmod(0o100600)
196196
yield key_path
197197
finally:
198198
# make sure to cleanup the test since we put a file in ~/.sfapi_test
@@ -204,12 +204,12 @@ def fake_key_file(tmp_path_factory):
204204

205205
@pytest.fixture
206206
def empty_key_file(tmp_path_factory):
207-
tmp_path_factory._basetemp = Path().home()
208-
key_path = tmp_path_factory.mktemp(".sfapi_test2", numbered=False) / "nokey.pem"
209-
# Makes an empty key
210-
key_path.write_text("")
211-
key_path.chmod(0o100600)
212207
try:
208+
tmp_path_factory._basetemp = Path().home()
209+
key_path = tmp_path_factory.mktemp(".sfapi_test2", numbered=False) / "nokey.pem"
210+
# Makes an empty key
211+
key_path.write_text("")
212+
key_path.chmod(0o100600)
213213
yield key_path
214214
finally:
215215
# make sure to cleanup the test since we put a file in ~/.sfapi_test

0 commit comments

Comments
 (0)