From 1a3b84060dabdedc8abbe92baac237f2a4995de5 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Tue, 24 Sep 2019 19:32:01 +0300 Subject: [PATCH] Add functional tests for 'yanked' files --- news/6653.trivial | 1 + tests/data/indexes/yanked/simple/index.html | 7 +++++ tests/functional/test_install.py | 30 +++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 news/6653.trivial create mode 100644 tests/data/indexes/yanked/simple/index.html diff --git a/news/6653.trivial b/news/6653.trivial new file mode 100644 index 000000000..5ef02a000 --- /dev/null +++ b/news/6653.trivial @@ -0,0 +1 @@ +Add functional tests for "yanked" files. diff --git a/tests/data/indexes/yanked/simple/index.html b/tests/data/indexes/yanked/simple/index.html new file mode 100644 index 000000000..bf4994310 --- /dev/null +++ b/tests/data/indexes/yanked/simple/index.html @@ -0,0 +1,7 @@ + + + simple-1.0.tar.gz + simple-2.0.tar.gz + simple-3.0.tar.gz + + diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index 7a0e4a9cb..8ce2c8499 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -1657,3 +1657,33 @@ def test_install_pip_does_not_modify_pip_when_satisfied( 'pip', *install_args, use_module=use_module ) assert expected_message in result.stdout, str(result) + + +def test_ignore_yanked_file(script, data): + """ + Test ignore a "yanked" file. + """ + result = script.pip( + 'install', 'simple', + '--index-url', data.index_url('yanked'), + ) + # Make sure a "yanked" release ignored + assert 'Successfully installed simple-2.0\n' in result.stdout, str(result) + + +def test_install_yanked_file_and_print_warning(script, data): + """ + Test install a "yanked" file and warn a reason. + + Yanked files are always ignored, unless they are the only file that + matches a version specifier that "pins" to an exact version (PEP 592). + """ + result = script.pip( + 'install', 'simple==3.0', + '--index-url', data.index_url('yanked'), + expect_stderr=True, + ) + expected_warning = 'Reason for being yanked: test reason message' + assert expected_warning in result.stderr, str(result) + # Make sure a "yanked" release installed + assert 'Successfully installed simple-3.0\n' in result.stdout, str(result) -- GitLab