Skip to content

Commit

Permalink
Skip pip search tests unless explicitly requested
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Dec 15, 2020
1 parent 2b0b426 commit 145be2e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ markers =
mercurial: VCS: Mercurial
git: VCS: git
yaml: yaml based tests
search: tests for 'pip search'

[coverage:run]
branch = True
Expand Down
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,23 @@ def pytest_addoption(parser):
default=False,
help="use venv for virtual environment creation",
)
parser.addoption(
"--run-search",
action="store_true",
default=False,
help="run 'pip search' tests",
)


def pytest_collection_modifyitems(config, items):
for item in items:
if not hasattr(item, 'module'): # e.g.: DoctestTextfile
continue

if (item.get_closest_marker('search') and
not config.getoption('--run-search')):
item.add_marker(pytest.mark.skip('pip search test skipped'))

if "CI" in os.environ:
# Mark network tests as flaky
if item.get_closest_marker('network') is not None:
Expand Down
9 changes: 9 additions & 0 deletions tests/functional/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def test_pypi_xml_transformation():


@pytest.mark.network
@pytest.mark.search
def test_basic_search(script):
"""
End to end test of search command.
Expand All @@ -75,6 +76,7 @@ def test_basic_search(script):
"https://github.com/pypa/warehouse/issues/3717 for more "
"information."),
)
@pytest.mark.search
def test_multiple_search(script):
"""
Test searching for multiple packages at once.
Expand All @@ -88,6 +90,7 @@ def test_multiple_search(script):
assert 'Tools for parsing and using INI-style files' in output.stdout


@pytest.mark.search
def test_search_missing_argument(script):
"""
Test missing required argument for search
Expand All @@ -97,6 +100,7 @@ def test_search_missing_argument(script):


@pytest.mark.network
@pytest.mark.search
def test_run_method_should_return_success_when_find_packages():
"""
Test SearchCommand.run for found package
Expand All @@ -110,6 +114,7 @@ def test_run_method_should_return_success_when_find_packages():


@pytest.mark.network
@pytest.mark.search
def test_run_method_should_return_no_matches_found_when_does_not_find_pkgs():
"""
Test SearchCommand.run for no matches
Expand All @@ -123,6 +128,7 @@ def test_run_method_should_return_no_matches_found_when_does_not_find_pkgs():


@pytest.mark.network
@pytest.mark.search
def test_search_should_exit_status_code_zero_when_find_packages(script):
"""
Test search exit status code for package found
Expand All @@ -132,6 +138,7 @@ def test_search_should_exit_status_code_zero_when_find_packages(script):


@pytest.mark.network
@pytest.mark.search
def test_search_exit_status_code_when_finds_no_package(script):
"""
Test search exit status code for no matches
Expand All @@ -140,6 +147,7 @@ def test_search_exit_status_code_when_finds_no_package(script):
assert result.returncode == NO_MATCHES_FOUND, result.returncode


@pytest.mark.search
def test_latest_prerelease_install_message(caplog, monkeypatch):
"""
Test documentation for installing pre-release packages is displayed
Expand Down Expand Up @@ -168,6 +176,7 @@ def test_latest_prerelease_install_message(caplog, monkeypatch):
assert get_dist.calls == [pretend.call('ni')]


@pytest.mark.search
def test_search_print_results_should_contain_latest_versions(caplog):
"""
Test that printed search results contain the latest package versions
Expand Down

0 comments on commit 145be2e

Please sign in to comment.