• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import sys
2
3import pytest
4
5
6pytest_plugins = 'setuptools.tests.fixtures'
7
8
9def pytest_addoption(parser):
10    parser.addoption(
11        "--package_name", action="append", default=[],
12        help="list of package_name to pass to test functions",
13    )
14    parser.addoption(
15        "--integration", action="store_true", default=False,
16        help="run integration tests (only)"
17    )
18
19
20def pytest_configure(config):
21    config.addinivalue_line("markers", "integration: integration tests")
22    config.addinivalue_line("markers", "uses_network: tests may try to download files")
23
24
25collect_ignore = [
26    'tests/manual_test.py',
27    'setuptools/tests/mod_with_constant.py',
28    'setuptools/_distutils',
29    '_distutils_hack',
30    'setuptools/extern',
31    'pkg_resources/extern',
32    'pkg_resources/tests/data',
33    'setuptools/_vendor',
34    'pkg_resources/_vendor',
35]
36
37
38if sys.version_info < (3, 6):
39    collect_ignore.append('docs/conf.py')  # uses f-strings
40    collect_ignore.append('pavement.py')
41
42
43@pytest.fixture(autouse=True)
44def _skip_integration(request):
45    running_integration_tests = request.config.getoption("--integration")
46    is_integration_test = request.node.get_closest_marker("integration")
47    if running_integration_tests and not is_integration_test:
48        pytest.skip("running integration tests only")
49    if not running_integration_tests and is_integration_test:
50        pytest.skip("skipping integration tests")
51