Skip to content

Commit 76cad73

Browse files
committed
toggle some tests based upon docker availability, not OS
1 parent 7988d78 commit 76cad73

File tree

8 files changed

+24
-37
lines changed

8 files changed

+24
-37
lines changed

tests/test_check.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
import cwltool.workflow
99
import pytest
1010
from cwltool.main import main
11-
from cwltool.utils import onWindows
1211

13-
from .util import get_data
12+
from .util import get_data, needs_docker
1413

1514

1615
class TestCheck(unittest.TestCase):
17-
@pytest.mark.skipif(onWindows(),
18-
reason="Instance of Cwltool is used, On windows that invoke a default docker Container")
16+
@needs_docker
1917
def test_output_checking(self):
2018
self.assertEquals(main([get_data('tests/wf/badout1.cwl')]), 1)
2119
self.assertEquals(main([get_data('tests/wf/badout2.cwl')]), 1)

tests/test_examples.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from io import StringIO
99

1010
from cwltool.errors import WorkflowException
11-
from cwltool.utils import onWindows
1211

1312
try:
1413
reload
@@ -26,7 +25,7 @@
2625
import schema_salad.validate
2726
from cwltool.main import main
2827

29-
from .util import get_data
28+
from .util import get_data, needs_docker
3029

3130
sys.argv = ['']
3231

@@ -603,9 +602,7 @@ def test_no_js_console(self):
603602
self.assertNotIn("[err] Error message", stderr)
604603

605604

606-
@pytest.mark.skipif(onWindows(),
607-
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
608-
"which is not supported on AppVeyor")
605+
@needs_docker
609606
class TestCache(TestCmdLine):
610607
def test_wf_without_container(self):
611608
test_file = "hello-workflow.cwl"
@@ -614,9 +611,7 @@ def test_wf_without_container(self):
614611
self.assertIn("completed success", stderr)
615612
self.assertEquals(error_code, 0)
616613

617-
@pytest.mark.skipif(onWindows(),
618-
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
619-
"which is not supported on AppVeyor")
614+
@needs_docker
620615
class TestChecksum(TestCmdLine):
621616

622617
def test_compute_checksum(self):

tests/test_ext.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
import cwltool.workflow
1212
from cwltool.main import main
1313
from cwltool.utils import onWindows
14-
from .util import get_data
14+
from .util import get_data, needs_docker
1515

1616

17-
@pytest.mark.skipif(onWindows(),
18-
reason="Instance of Cwltool is used, On windows that invoke a default docker Container")
17+
@needs_docker
1918
class TestListing(unittest.TestCase):
2019
def test_missing_enable_ext(self):
2120
# Require that --enable-ext is provided.

tests/test_override.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
import pytest
99
import json
1010
from cwltool.main import main
11-
from cwltool.utils import onWindows
1211
from six import StringIO
1312

14-
from .util import get_data
13+
from .util import get_data, needs_docker
1514

1615

1716
class TestOverride(unittest.TestCase):
18-
@pytest.mark.skipif(onWindows(),
19-
reason="Instance of Cwltool is used, On windows that invoke a default docker Container")
17+
@needs_docker
2018
def test_overrides(self):
2119
sio = StringIO()
2220

tests/test_pack.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
from cwltool.load_tool import fetch_document, validate_document
1818
from cwltool.main import makeRelative, main, print_pack
1919
from cwltool.pathmapper import adjustDirObjs, adjustFileObjs
20-
from cwltool.utils import onWindows
21-
from .util import get_data
20+
from .util import get_data, needs_docker
2221

2322

2423
class TestPack(unittest.TestCase):
@@ -96,9 +95,7 @@ def _pack_idempotently(self, document):
9695
double_packed = json.loads(print_pack(document_loader, processobj, uri2, metadata))
9796
self.assertEqual(packed, double_packed)
9897

99-
@pytest.mark.skipif(onWindows(),
100-
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
101-
"which is not supported on AppVeyor")
98+
@needs_docker
10299
def test_packed_workflow_execution(self):
103100
load_tool.loaders = {}
104101
test_wf = "tests/wf/count-lines1-wf.cwl"
@@ -122,9 +119,7 @@ def test_packed_workflow_execution(self):
122119
self.assertEquals(json.loads(packed_output.getvalue()), json.loads(normal_output.getvalue()))
123120
os.remove(temp_packed_path)
124121

125-
@pytest.mark.skipif(onWindows(),
126-
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
127-
"which is not supported on AppVeyor")
122+
@needs_docker
128123
def test_preserving_namespaces(self):
129124
test_wf = "tests/wf/formattest.cwl"
130125
test_wf_job = "tests/wf/formattest-job.json"

tests/test_relax_path_checks.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import pytest
44
from tempfile import NamedTemporaryFile
55

6+
from .util import needs_docker
67
from cwltool.main import main
7-
from cwltool.utils import onWindows
88

99

1010
class ToolArgparse(unittest.TestCase):
@@ -26,8 +26,7 @@ class ToolArgparse(unittest.TestCase):
2626
baseCommand: [cat]
2727
'''
2828

29-
@pytest.mark.skipif(onWindows(),
30-
reason="Instance of Cwltool is used, On windows that invoke a default docker Container")
29+
@needs_docker
3130
def test_spaces_in_input_files(self):
3231
with NamedTemporaryFile(mode='w', delete=False) as f:
3332
f.write(self.script)

tests/test_toolargparse.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
from tempfile import NamedTemporaryFile
55

66
from cwltool.main import main
7-
from cwltool.utils import onWindows
87

9-
from .util import get_data
8+
from .util import get_data, needs_docker
109

1110
class ToolArgparse(unittest.TestCase):
1211
script = '''
@@ -66,8 +65,7 @@ class ToolArgparse(unittest.TestCase):
6665
outputs: []
6766
'''
6867

69-
@pytest.mark.skipif(onWindows(),
70-
reason="Instance of Cwltool is used, On windows that invoke a default docker Container")
68+
@needs_docker
7169
def test_help(self):
7270
with NamedTemporaryFile(mode='w', delete=False) as f:
7371
f.write(self.script)
@@ -79,8 +77,7 @@ def test_help(self):
7977
get_data('tests/echo.cwl')]), 0)
8078

8179

82-
@pytest.mark.skipif(onWindows(),
83-
reason="Instance of Cwltool is used, On windows that invoke a default docker Container")
80+
@needs_docker
8481
def test_bool(self):
8582
with NamedTemporaryFile(mode='w', delete=False) as f:
8683
f.write(self.script2)

tests/util.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
from pkg_resources import (Requirement, ResolutionError, # type: ignore
55
resource_filename)
6-
6+
import distutils.spawn
7+
import pytest
78

89
def get_data(filename):
910
filename = os.path.normpath(
@@ -17,3 +18,8 @@ def get_data(filename):
1718
if not filepath or not os.path.isfile(filepath):
1819
filepath = os.path.join(os.path.dirname(__file__), os.pardir, filename)
1920
return filepath
21+
22+
23+
needs_docker = pytest.mark.skipif(not bool(distutils.spawn.find_executable('docker')),
24+
reason="Requires the docker executable on the "
25+
"system path.")

0 commit comments

Comments
 (0)