mirror of
https://github.com/docker/compose.git
synced 2025-07-29 00:24:12 +02:00
Fix if_runtime_available decorator
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
f22a1b6a2e
commit
74f616f208
@ -834,11 +834,11 @@ class ProjectTest(DockerClientTestCase):
|
|||||||
|
|
||||||
service_container = project.get_service('web').containers()[0]
|
service_container = project.get_service('web').containers()[0]
|
||||||
|
|
||||||
IPAMConfig = (service_container.inspect().get('NetworkSettings', {}).
|
ipam_config = (service_container.inspect().get('NetworkSettings', {}).
|
||||||
get('Networks', {}).get('composetest_static_test', {}).
|
get('Networks', {}).get('composetest_static_test', {}).
|
||||||
get('IPAMConfig', {}))
|
get('IPAMConfig', {}))
|
||||||
assert IPAMConfig.get('IPv4Address') == '172.16.100.100'
|
assert ipam_config.get('IPv4Address') == '172.16.100.100'
|
||||||
assert IPAMConfig.get('IPv6Address') == 'fe80::1001:102'
|
assert ipam_config.get('IPv6Address') == 'fe80::1001:102'
|
||||||
|
|
||||||
@v2_1_only()
|
@v2_1_only()
|
||||||
def test_up_with_enable_ipv6(self):
|
def test_up_with_enable_ipv6(self):
|
||||||
@ -1032,6 +1032,7 @@ class ProjectTest(DockerClientTestCase):
|
|||||||
project.up()
|
project.up()
|
||||||
|
|
||||||
@v2_3_only()
|
@v2_3_only()
|
||||||
|
@if_runtime_available('runc')
|
||||||
def test_up_with_runtime(self):
|
def test_up_with_runtime(self):
|
||||||
self.require_api_version('1.30')
|
self.require_api_version('1.30')
|
||||||
config_data = build_config(
|
config_data = build_config(
|
||||||
|
@ -5,7 +5,6 @@ import functools
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import six
|
|
||||||
from docker.errors import APIError
|
from docker.errors import APIError
|
||||||
from docker.utils import version_lt
|
from docker.utils import version_lt
|
||||||
|
|
||||||
@ -157,22 +156,15 @@ class DockerClientTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
def if_runtime_available(runtime):
|
def if_runtime_available(runtime):
|
||||||
if runtime == 'nvidia':
|
def decorator(f):
|
||||||
command = 'nvidia-container-runtime'
|
@functools.wraps(f)
|
||||||
if six.PY3:
|
def wrapper(self, *args, **kwargs):
|
||||||
import shutil
|
if runtime not in self.client.info().get('Runtimes', {}):
|
||||||
return pytest.mark.skipif(
|
return pytest.skip("This daemon does not support the '{}'' runtime".format(runtime))
|
||||||
shutil.which(command) is None,
|
return f(self, *args, **kwargs)
|
||||||
reason="Nvida runtime not exists"
|
return wrapper
|
||||||
)
|
|
||||||
return pytest.mark.skipif(
|
return decorator
|
||||||
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 is_cluster(client):
|
def is_cluster(client):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user