Change 'slow' tests to 'docker' tests, only run them on Linux
This commit is contained in:
+5
-1
@@ -10,7 +10,11 @@ if __name__ == '__main__':
|
|||||||
os.chdir(Path(__file__).resolve().parents[1])
|
os.chdir(Path(__file__).resolve().parents[1])
|
||||||
|
|
||||||
# run the unit tests
|
# 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
|
# run the integration tests
|
||||||
subprocess.check_call([sys.executable, '-m', 'pytest', '-x', '--durations', '0', 'test'])
|
subprocess.check_call([sys.executable, '-m', 'pytest', '-x', '--durations', '0', 'test'])
|
||||||
|
|||||||
@@ -3,19 +3,19 @@ import pytest
|
|||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addoption(
|
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):
|
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):
|
def pytest_collection_modifyitems(config, items):
|
||||||
if config.getoption("--runslow"):
|
if config.getoption("--run-docker"):
|
||||||
# --runslow given in cli: do not skip slow tests
|
# --run-docker given in cli: do not skip docker tests
|
||||||
return
|
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:
|
for item in items:
|
||||||
if "slow" in item.keywords:
|
if "docker" in item.keywords:
|
||||||
item.add_marker(skip_slow)
|
item.add_marker(skip_docker)
|
||||||
|
|||||||
@@ -8,25 +8,25 @@ from cibuildwheel.docker_container import DockerContainer
|
|||||||
DEFAULT_IMAGE = 'centos:6'
|
DEFAULT_IMAGE = 'centos:6'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.slow
|
@pytest.mark.docker
|
||||||
def test_simple():
|
def test_simple():
|
||||||
with DockerContainer(DEFAULT_IMAGE) as container:
|
with DockerContainer(DEFAULT_IMAGE) as container:
|
||||||
assert container.call(['echo', 'hello'], capture_output=True) == 'hello\n'
|
assert container.call(['echo', 'hello'], capture_output=True) == 'hello\n'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.slow
|
@pytest.mark.docker
|
||||||
def test_no_lf():
|
def test_no_lf():
|
||||||
with DockerContainer(DEFAULT_IMAGE) as container:
|
with DockerContainer(DEFAULT_IMAGE) as container:
|
||||||
assert container.call(['printf', 'hello'], capture_output=True) == 'hello'
|
assert container.call(['printf', 'hello'], capture_output=True) == 'hello'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.slow
|
@pytest.mark.docker
|
||||||
def test_environment():
|
def test_environment():
|
||||||
with DockerContainer(DEFAULT_IMAGE) as container:
|
with DockerContainer(DEFAULT_IMAGE) as container:
|
||||||
assert container.call(['sh', '-c', 'echo $TEST_VAR'], env={'TEST_VAR': '1'}, capture_output=True) == '1\n'
|
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():
|
def test_container_removed():
|
||||||
with DockerContainer(DEFAULT_IMAGE) as container:
|
with DockerContainer(DEFAULT_IMAGE) as container:
|
||||||
# call a command to ensure it has started
|
# 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
|
assert old_container_name not in docker_containers_listing
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.slow
|
@pytest.mark.docker
|
||||||
def test_large_environment():
|
def test_large_environment():
|
||||||
# max environment variable size is 128kB
|
# max environment variable size is 128kB
|
||||||
long_env_var_length = 127*1024
|
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'
|
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():
|
def test_binary_output():
|
||||||
with DockerContainer(DEFAULT_IMAGE) as container:
|
with DockerContainer(DEFAULT_IMAGE) as container:
|
||||||
# the centos image only has python 2.6, so the below embedded snippets
|
# the centos image only has python 2.6, so the below embedded snippets
|
||||||
|
|||||||
Reference in New Issue
Block a user