diff --git a/bin/run_tests.py b/bin/run_tests.py index 1a1895cf..17f06aa5 100755 --- a/bin/run_tests.py +++ b/bin/run_tests.py @@ -10,7 +10,11 @@ if __name__ == '__main__': os.chdir(Path(__file__).resolve().parents[1]) # run the unit tests - subprocess.check_call([sys.executable, '-m', 'pytest', 'unit_test', '--runslow']) + unit_test_args = [sys.executable, '-m', 'pytest', 'unit_test'] + # run the docker unit tests only on Linux + if sys.platform.startswith('linux'): + unit_test_args += ['--run-docker'] + subprocess.check_call(unit_test_args) # run the integration tests subprocess.check_call([sys.executable, '-m', 'pytest', '-x', '--durations', '0', 'test']) diff --git a/unit_test/conftest.py b/unit_test/conftest.py index e446d0a1..a54658a9 100644 --- a/unit_test/conftest.py +++ b/unit_test/conftest.py @@ -3,19 +3,19 @@ import pytest def pytest_addoption(parser): parser.addoption( - "--runslow", action="store_true", default=False, help="run slow tests" + "--run-docker", action="store_true", default=False, help="run docker tests" ) def pytest_configure(config): - config.addinivalue_line("markers", "slow: mark test as slow to run") + config.addinivalue_line("markers", "docker: mark test requiring docker to run") def pytest_collection_modifyitems(config, items): - if config.getoption("--runslow"): - # --runslow given in cli: do not skip slow tests + if config.getoption("--run-docker"): + # --run-docker given in cli: do not skip docker tests return - skip_slow = pytest.mark.skip(reason="need --runslow option to run") + skip_docker = pytest.mark.skip(reason="need --run-docker option to run") for item in items: - if "slow" in item.keywords: - item.add_marker(skip_slow) + if "docker" in item.keywords: + item.add_marker(skip_docker) diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index 7e124d38..cba0fb50 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -8,25 +8,25 @@ from cibuildwheel.docker_container import DockerContainer DEFAULT_IMAGE = 'centos:6' -@pytest.mark.slow +@pytest.mark.docker def test_simple(): with DockerContainer(DEFAULT_IMAGE) as container: assert container.call(['echo', 'hello'], capture_output=True) == 'hello\n' -@pytest.mark.slow +@pytest.mark.docker def test_no_lf(): with DockerContainer(DEFAULT_IMAGE) as container: assert container.call(['printf', 'hello'], capture_output=True) == 'hello' -@pytest.mark.slow +@pytest.mark.docker def test_environment(): with DockerContainer(DEFAULT_IMAGE) as container: assert container.call(['sh', '-c', 'echo $TEST_VAR'], env={'TEST_VAR': '1'}, capture_output=True) == '1\n' -@pytest.mark.slow +@pytest.mark.docker def test_container_removed(): with DockerContainer(DEFAULT_IMAGE) as container: # call a command to ensure it has started @@ -39,7 +39,7 @@ def test_container_removed(): assert old_container_name not in docker_containers_listing -@pytest.mark.slow +@pytest.mark.docker def test_large_environment(): # max environment variable size is 128kB long_env_var_length = 127*1024 @@ -55,7 +55,7 @@ def test_large_environment(): assert container.call(['sh', '-c', 'echo ${#d}'], env=large_environment, capture_output=True) == f'{long_env_var_length}\n' -@pytest.mark.slow +@pytest.mark.docker def test_binary_output(): with DockerContainer(DEFAULT_IMAGE) as container: # the centos image only has python 2.6, so the below embedded snippets