From 25cb146820d8c7bdf1f2f4b0fc6ddb4137b1e346 Mon Sep 17 00:00:00 2001 From: Guillaume EB Date: Mon, 12 Sep 2022 12:25:10 +0400 Subject: [PATCH] Re adding test test_jobqueue_cluster_call --- .gitignore | 1 + dask_jobqueue/tests/test_job.py | 26 +++++++++++++++++++++++ dask_jobqueue/tests/test_jobqueue_core.py | 25 ---------------------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 11f73aea..23a75ada 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ ci/slurm/environment.yml ci/pbs/environment.yml ci/sge/environment.yml ci/htcondor/environment.yml +.vscode/ diff --git a/dask_jobqueue/tests/test_job.py b/dask_jobqueue/tests/test_job.py index 3325bbfd..8ac62a3d 100644 --- a/dask_jobqueue/tests/test_job.py +++ b/dask_jobqueue/tests/test_job.py @@ -1,5 +1,7 @@ import asyncio from time import time +import sys +import re from dask_jobqueue import PBSCluster, SLURMCluster, SGECluster, OARCluster @@ -428,3 +430,27 @@ def test_deprecation_job_extra(Cluster): ) job_script = job.job_script() assert "old_param" in job_script + + +def test_jobqueue_job_call(tmpdir, Cluster): + cluster = Cluster(cores=1, memory="1GB") + + path = tmpdir.join("test.py") + path.write('print("this is the stdout")') + + out = cluster.job_cls._call([sys.executable, path.strpath]) + assert out == "this is the stdout\n" + + path_with_error = tmpdir.join("non-zero-exit-code.py") + path_with_error.write('print("this is the stdout")\n1/0') + + match = ( + "Command exited with non-zero exit code.+" + "Exit code: 1.+" + "stdout:\nthis is the stdout.+" + "stderr:.+ZeroDivisionError" + ) + + match = re.compile(match, re.DOTALL) + with pytest.raises(RuntimeError, match=match): + cluster.job_cls._call([sys.executable, path_with_error.strpath]) diff --git a/dask_jobqueue/tests/test_jobqueue_core.py b/dask_jobqueue/tests/test_jobqueue_core.py index a21303fd..0afb20c7 100644 --- a/dask_jobqueue/tests/test_jobqueue_core.py +++ b/dask_jobqueue/tests/test_jobqueue_core.py @@ -169,31 +169,6 @@ def test_log_directory(Cluster, tmpdir): assert os.path.exists(tmpdir.strpath) -@pytest.mark.skip -def test_jobqueue_cluster_call(tmpdir, Cluster): - cluster = Cluster(cores=1, memory="1GB") - - path = tmpdir.join("test.py") - path.write('print("this is the stdout")') - - out = cluster._call([sys.executable, path.strpath]) - assert out == "this is the stdout\n" - - path_with_error = tmpdir.join("non-zero-exit-code.py") - path_with_error.write('print("this is the stdout")\n1/0') - - match = ( - "Command exited with non-zero exit code.+" - "Exit code: 1.+" - "stdout:\nthis is the stdout.+" - "stderr:.+ZeroDivisionError" - ) - - match = re.compile(match, re.DOTALL) - with pytest.raises(RuntimeError, match=match): - cluster._call([sys.executable, path_with_error.strpath]) - - def test_cluster_has_cores_and_memory(Cluster): base_regex = r"{}.+".format(Cluster.__name__) with pytest.raises(ValueError, match=base_regex + r"cores=\d, memory='\d+GB'"):