Skip to content

Commit 88c7a9f

Browse files
committed
Fix tests failing due to argparse difference per version
3.9 uses `optional arguments:` 3.10+ uses `options:` This means we can't do explicit comparisons (without checking the version) So we compromise by checking an expected value in the output.
1 parent 7bae819 commit 88c7a9f

1 file changed

Lines changed: 5 additions & 16 deletions

File tree

tests/test_cli.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ def test_run(self, args: Sequence[str], output: str, exit_code: int):
1414
cmd = subprocess.run(_args, capture_output=True, text=True)
1515
result = cmd.stdout
1616
status = cmd.returncode
17-
print("= = =")
18-
print(result) # Visual Aid for Debugging
19-
print("= = =")
20-
assert result == output
17+
print(f"'{result}'") # Visual Aid for Debugging
18+
assert output in result
2119
assert status == exit_code
2220

2321
def test_run_with(self, args: Sequence[str], output: str, exit_code: int):
@@ -27,20 +25,11 @@ def test_run_with(self, args: Sequence[str], output: str, exit_code: int):
2725
status = cli_root.run_with(*args)
2826
f.seek(0)
2927
result = f.read()
30-
print("= = =")
31-
print(result) # Visual Aid for Debugging
32-
print("= = =")
33-
assert result == output
28+
print(f"'{result}'") # Visual Aid for Debugging
29+
assert output in result
3430
assert status == exit_code
3531

36-
_HELP = ["-h"], """usage: relic [-h] {} ...
37-
38-
positional arguments:
39-
{}
40-
41-
optional arguments:
42-
-h, --help show this help message and exit
43-
""", 0
32+
_HELP = ["-h"], """usage: relic [-h] {} ...""", 0
4433

4534
_TESTS = [_HELP]
4635
_TEST_IDS = [' '.join(_[0]) for _ in _TESTS]

0 commit comments

Comments
 (0)