1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

[tests/functional/test_cache] Add test pip cache list with an empty cache.

This commit is contained in:
Ellen Marie Dash 2020-03-10 14:53:24 -04:00
parent 32ce3bacbe
commit ba7c3ac9ec

View file

@ -1,5 +1,6 @@
import os
import re
import shutil
from glob import glob
import pytest
@ -23,6 +24,10 @@ def wheel_cache_dir(cache_dir):
@pytest.fixture
def wheel_cache_files(wheel_cache_dir):
destination = os.path.join(wheel_cache_dir, 'arbitrary', 'pathname')
if not os.path.exists(destination):
return []
filenames = glob(os.path.join(destination, '*.whl'))
files = []
for filename in filenames:
@ -49,6 +54,12 @@ def populate_wheel_cache(wheel_cache_dir):
return files
@pytest.fixture
def empty_wheel_cache(wheel_cache_dir):
if os.path.exists(wheel_cache_dir):
shutil.rmtree(wheel_cache_dir)
def list_matches_wheel(wheel_name, lines):
"""Returns True if any line in `lines`, which should be the output of
a `pip cache list` call, matches `wheel_name`.
@ -102,6 +113,14 @@ def test_cache_list(script):
assert list_matches_wheel('zzz-7.8.9', lines)
@pytest.mark.usefixtures("empty_wheel_cache")
def test_cache_list_with_empty_cache(script):
"""Running `pip cache list` with an empty cache should print
"Nothing cached." and exit."""
result = script.pip('cache', 'list')
assert result.stdout == "Nothing cached.\n"
def test_cache_list_too_many_args(script):
"""Passing `pip cache list` too many arguments should cause an error."""
script.pip('cache', 'list', 'aaa', 'bbb',