Skip to content

Commit ed6f1f5

Browse files
[functional config test] Permit to tests argparse error in config
1 parent 9f8dcbd commit ed6f1f5

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

tests/config/test_functional_config_loading.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,24 @@ def test_functional_config_loading(
8282
expected_loaded_configuration = get_expected_configuration(
8383
configuration_path, default_configuration
8484
)
85+
runner = None # The runner can fail to init if conf is bad enough.
8586
with warnings.catch_warnings():
8687
warnings.filterwarnings(
8788
"ignore", message="The use of 'MASTER'.*", category=UserWarning
8889
)
89-
runner = run_using_a_configuration_file(configuration_path, file_to_lint_path)
90-
assert runner.linter.msg_status == expected_code
90+
try:
91+
runner = run_using_a_configuration_file(
92+
configuration_path, file_to_lint_path
93+
)
94+
assert runner.linter.msg_status == expected_code
95+
except SystemExit as e:
96+
# Case where the conf exit with an argparse error
97+
assert e.code == expected_code
98+
out, err = capsys.readouterr()
99+
assert out == ""
100+
assert err.rstrip() == expected_output.rstrip()
101+
return
102+
91103
out, err = capsys.readouterr()
92104
# 'rstrip()' applied, so we can have a final newline in the expected test file
93105
assert expected_output.rstrip() == out.rstrip(), msg

0 commit comments

Comments
 (0)