Merge pull request #9291 from uranusjr/skip-search-tests

Skip pip search tests unless explicitly requested
This commit is contained in:
Pradyun Gedam 2020-12-15 10:01:36 +00:00 committed by GitHub
commit 03d5f56b10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View File

@ -61,6 +61,7 @@ markers =
mercurial: VCS: Mercurial
git: VCS: git
yaml: yaml based tests
search: tests for 'pip search'
[coverage:run]
branch = True

View File

@ -51,6 +51,12 @@ 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):
@ -58,6 +64,10 @@ def pytest_collection_modifyitems(config, 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:

View File

@ -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.
@ -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.
@ -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
@ -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
@ -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
@ -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
@ -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
@ -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
@ -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