Skip to content
Snippets Groups Projects
Unverified Commit ba7ac161 authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

Remove duplicate test_func_to_cmd test

This test is already defined in test_run.py
parent 444d4cfe
No related branches found
No related tags found
No related merge requests found
...@@ -239,45 +239,4 @@ def test_info(): ...@@ -239,45 +239,4 @@ def test_info():
assert res2['1'] is None assert res2['1'] is None
with pytest.raises(ValueError): with pytest.raises(ValueError):
fslsub._parse_qstat(valid_job_ids[0], example_qstat_reply) fslsub._parse_qstat(valid_job_ids[0], example_qstat_reply)
\ No newline at end of file
def _good_func():
print('hello')
def _bad_func():
1/0
def test_func_to_cmd():
cwd = os.getcwd()
with tempdir():
for tmp_dir in (None, '.'):
for clean in ('never', 'on_success', 'always'):
for verbose in (False, True):
cmd = fslsub.func_to_cmd(_good_func, clean=clean, tmp_dir=tmp_dir, verbose=verbose)
fn = cmd.split()[-1]
assert op.exists(fn)
stdout, stderr, exitcode = run.run(cmd, exitcode=True, stdout=True, stderr=True,
env={"PYTHONPATH": cwd})
assert exitcode == 0
if clean == 'never':
assert op.exists(fn), "Successful job got removed, even though this was not requested"
else:
assert not op.exists(fn), f"Successful job did not get removed after run for clean = {clean}"
if verbose:
assert stdout.strip() == f'running "{fn}"\nhello'
else:
assert stdout.strip() == 'hello'
cmd = fslsub.func_to_cmd(_bad_func, clean=clean, tmp_dir=tmp_dir)
fn = cmd.split()[-1]
assert op.exists(fn)
stdout, stderr, exitcode = run.run(cmd, exitcode=True, stdout=True, stderr=True,
env={'PYTHONPATH': cwd})
assert exitcode != 0
if clean == 'always':
assert not op.exists(fn), "Failing job should always be removed if requested"
else:
assert op.exists(fn), f"Failing job got removed even with clean = {clean}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment