diff --git a/test/runner/lib/delegation.py b/test/runner/lib/delegation.py index a5de0e0332f..0a63754defa 100644 --- a/test/runner/lib/delegation.py +++ b/test/runner/lib/delegation.py @@ -16,6 +16,7 @@ from lib.executor import ( SubprocessError, ShellConfig, SanityConfig, + UnitsConfig, create_shell_command, ) @@ -201,6 +202,10 @@ def delegate_docker(args, exclude, require): docker_exec(args, test_id, ['mkdir', '/root/ansible']) docker_exec(args, test_id, ['tar', 'oxzf', '/root/ansible.tgz', '-C', '/root/ansible']) + # docker images are only expected to have a single python version available + if isinstance(args, UnitsConfig) and not args.python: + cmd += ['--python', 'default'] + try: docker_exec(args, test_id, cmd, options=cmd_options) finally: @@ -356,6 +361,10 @@ def delegate_remote(args, exclude, require): if not args.allow_destructive: cmd.append('--allow-destructive') + # remote instances are only expected to have a single python version available + if isinstance(args, UnitsConfig) and not args.python: + cmd += ['--python', 'default'] + manage = ManagePosixCI(core_ci) manage.setup() diff --git a/test/runner/lib/util.py b/test/runner/lib/util.py index 3607268e34a..74942d4b573 100644 --- a/test/runner/lib/util.py +++ b/test/runner/lib/util.py @@ -477,6 +477,9 @@ class EnvironmentConfig(CommonConfig): self.requirements = args.requirements # type: bool + if self.python == 'default': + self.python = '.'.join(str(i) for i in sys.version_info[:2]) + self.python_version = self.python or '.'.join(str(i) for i in sys.version_info[:2]) self.delegate = self.tox or self.docker or self.remote diff --git a/test/runner/requirements/units.txt b/test/runner/requirements/units.txt index 085c9ab63c0..26bcd641b25 100644 --- a/test/runner/requirements/units.txt +++ b/test/runner/requirements/units.txt @@ -12,5 +12,6 @@ pytest-xdist python-memcached pyyaml redis +setuptools > 0.6 # pytest-xdist installed via requirements does not work with very old setuptools (sanity_ok) unittest2 ; python_version < '2.7' netaddr diff --git a/test/runner/test.py b/test/runner/test.py index 56fc4a76621..801f07f9634 100755 --- a/test/runner/test.py +++ b/test/runner/test.py @@ -241,7 +241,7 @@ def parse_args(): units.add_argument('--python', metavar='VERSION', - choices=SUPPORTED_PYTHON_VERSIONS, + choices=SUPPORTED_PYTHON_VERSIONS + ('default',), help='python version: %s' % ', '.join(SUPPORTED_PYTHON_VERSIONS)) units.add_argument('--collect-only', diff --git a/test/sanity/code-smell/test-constraints.sh b/test/sanity/code-smell/test-constraints.sh index 0bbaad53b07..773306c4d0a 100755 --- a/test/sanity/code-smell/test-constraints.sh +++ b/test/sanity/code-smell/test-constraints.sh @@ -2,6 +2,7 @@ constraints=$( grep '.' test/runner/requirements/*.txt \ + | grep -v '(sanity_ok)$' \ | sed 's/ *;.*$//; s/ #.*$//' \ | grep -v '/constraints.txt:' \ | grep '[<>=]' diff --git a/test/units/conftest.py b/test/units/conftest.py index 387fa77b87f..2cd1f74596b 100644 --- a/test/units/conftest.py +++ b/test/units/conftest.py @@ -7,6 +7,11 @@ try: except ImportError: coverage = None +try: + test = coverage.Coverage +except AttributeError: + coverage = None + def pytest_configure(): if not coverage: