Skip to content

Commit c8902c7

Browse files
committed
style: refactor test_toolargparse
1 parent 592a7e6 commit c8902c7

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

tests/test_toolargparse.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
),
7171
('boolean', script_b, lambda x: [x, '--help']
7272
),
73+
('help with c', script_c, lambda x: [x, '--help']),
74+
('foo with c', script_c,
75+
lambda x: [x, '--foo.one', get_data('tests/echo.cwl'), '--foo.two', 'test']
76+
)
7377
]
7478

7579
@needs_docker
@@ -78,34 +82,12 @@ def test_argparse(name, script_contents, params):
7882
try:
7983
script = NamedTemporaryFile(mode='w', delete=False)
8084
script.write(script_contents)
81-
script.flush()
8285
script.close()
8386

84-
try:
85-
assert main(params(script.name)) == 0, name
86-
except SystemExit as err:
87-
assert err.code == 0, name
88-
finally:
89-
if os.path.exists(script.name):
90-
os.remove(script.name)
91-
92-
script_c_params = [
93-
(lambda x: [x, '--help']),
94-
(lambda x: [x, '--foo.one', get_data('tests/echo.cwl'), '--foo.two', 'test'])
95-
]
96-
97-
@pytest.mark.parametrize('params', script_c_params)
98-
def test_argparse_record(params):
99-
try:
100-
script = NamedTemporaryFile(mode='w', delete=False)
101-
script.write(script_c)
102-
script.flush()
103-
script.close()
87+
assert main(params(script.name)) == 0, name
10488

105-
try:
106-
assert main(params(script.name)) == 0
107-
except SystemExit as err:
108-
assert err.code == 0
89+
except SystemExit as err:
90+
assert err.code == 0, name
10991
finally:
11092
if os.path.exists(script.name):
111-
os.remove(script.name)
93+
os.unlink(script.name)

0 commit comments

Comments
 (0)