Skip to content

Commit e8f02d4

Browse files
committed
update test case for invalid meta to check for sys exit
1 parent 3240c8b commit e8f02d4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/test_config.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,12 @@ def test_json_loading__failure():
236236
with open(filename, "w") as openfile:
237237
openfile.write("# yeah comments are ok\n{but invalid json: [is not]}")
238238

239-
with mock.patch.object(config.logging, "error") as patched_err_log:
240-
assert config.json_maybe_commented(filename) == {}
239+
with pytest.raises(SystemExit) as error:
240+
config.json_maybe_commented(filename)
241241

242-
assert patched_err_log.call_args[0][0] == "Error reading json from %s: %r"
243-
assert patched_err_log.call_args[0][1] == filename
244-
assert isinstance(patched_err_log.call_args[0][2], ValueError)
245-
assert patched_err_log.call_count == 1
242+
exit = error.exconly()
243+
assert "SystemExit: Error reading json from {}:".format(filename) in exit
244+
assert "Expecting property name" in exit
246245

247246

248247
@pytest.mark.parametrize("original, alias", [

0 commit comments

Comments
 (0)