Change 'slow' tests to 'docker' tests, only run them on Linux

This commit is contained in:
Joe Rickerby
2020-06-28 10:53:03 +01:00
parent 91c3e90017
commit faf6a76375
3 changed files with 18 additions and 14 deletions
+5 -1
View File
@@ -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'])
+7 -7
View File
@@ -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)
+6 -6
View File
@@ -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