From c02fc790c406919b1cb27aaaa7c1bd01e6cfa05a Mon Sep 17 00:00:00 2001 From: Noah Gorny Date: Fri, 24 Apr 2020 12:32:24 +0300 Subject: [PATCH] tests: commands: cache: Add no-cache-dir test case --- tests/functional/test_cache.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/functional/test_cache.py b/tests/functional/test_cache.py index a464ece7945..d7ab56de4b9 100644 --- a/tests/functional/test_cache.py +++ b/tests/functional/test_cache.py @@ -216,3 +216,15 @@ def test_cache_purge_too_many_args(script, wheel_cache_files): # Make sure nothing was deleted. for filename in wheel_cache_files: assert os.path.exists(filename) + + +@pytest.mark.parametrize("command", ["info", "list", "remove", "purge"]) +def test_cache_abort_when_no_cache_dir(script, command): + """Running any pip cache command when cache is disabled should + abort and print informative answer""" + result = script.pip('cache', command, '--no-cache-dir', + expect_error=True) + assert result.stdout == '' + + assert ('ERROR: pip cache commands can not function' + ' since cache is disabled.' in result.stderr.splitlines())