diff --git a/tests/integration/project_test.py b/tests/integration/project_test.py index 6c6959034..554998e1c 100644 --- a/tests/integration/project_test.py +++ b/tests/integration/project_test.py @@ -834,11 +834,11 @@ class ProjectTest(DockerClientTestCase): service_container = project.get_service('web').containers()[0] - IPAMConfig = (service_container.inspect().get('NetworkSettings', {}). - get('Networks', {}).get('composetest_static_test', {}). - get('IPAMConfig', {})) - assert IPAMConfig.get('IPv4Address') == '172.16.100.100' - assert IPAMConfig.get('IPv6Address') == 'fe80::1001:102' + ipam_config = (service_container.inspect().get('NetworkSettings', {}). + get('Networks', {}).get('composetest_static_test', {}). + get('IPAMConfig', {})) + assert ipam_config.get('IPv4Address') == '172.16.100.100' + assert ipam_config.get('IPv6Address') == 'fe80::1001:102' @v2_1_only() def test_up_with_enable_ipv6(self): @@ -1032,6 +1032,7 @@ class ProjectTest(DockerClientTestCase): project.up() @v2_3_only() + @if_runtime_available('runc') def test_up_with_runtime(self): self.require_api_version('1.30') config_data = build_config( diff --git a/tests/integration/testcases.py b/tests/integration/testcases.py index 1a3be6cfc..4440d771e 100644 --- a/tests/integration/testcases.py +++ b/tests/integration/testcases.py @@ -5,7 +5,6 @@ import functools import os import pytest -import six from docker.errors import APIError from docker.utils import version_lt @@ -157,22 +156,15 @@ class DockerClientTestCase(unittest.TestCase): def if_runtime_available(runtime): - if runtime == 'nvidia': - command = 'nvidia-container-runtime' - if six.PY3: - import shutil - return pytest.mark.skipif( - shutil.which(command) is None, - reason="Nvida runtime not exists" - ) - return pytest.mark.skipif( - any( - os.access(os.path.join(path, command), os.X_OK) - for path in os.environ["PATH"].split(os.pathsep) - ) is False, - reason="Nvida runtime not exists" - ) - return pytest.skip("Runtime %s not exists", runtime) + def decorator(f): + @functools.wraps(f) + def wrapper(self, *args, **kwargs): + if runtime not in self.client.info().get('Runtimes', {}): + return pytest.skip("This daemon does not support the '{}'' runtime".format(runtime)) + return f(self, *args, **kwargs) + return wrapper + + return decorator def is_cluster(client):