Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for do not prompt when --no-input flag is given #7712

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Empty file.
27 changes: 27 additions & 0 deletions tests/functional/test_no_input_arguement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from pip._internal.cli.base_command import ERROR
from tests.lib.server import (
authorization_response,
make_mock_server,
server_running,
)


def test_do_not_prompt_when_no_input_flag_given(script):
server = make_mock_server()
server.mock.side_effect = [
authorization_response(),
]

url = "https://{}:{}/simple".format(server.host, server.port)

args = ["install"]
args.extend(["--index-url", url])
args.append("requests")
args.append("--no-input")

with server_running(server):
result = script.pip(*args, expect_error=True)

assert "Could not find a version that satisfies the" in result.stderr
assert "No matching distribution found for requests" in result.stderr
assert result.returncode == ERROR
12 changes: 12 additions & 0 deletions tests/lib/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def _mock_wsgi_adapter(mock):
"""Uses a mock to record function arguments and provide
the actual function that should respond.
"""

def adapter(environ, start_response):
# type: (Environ, StartResponse) -> Body
responder = mock(environ, start_response)
Expand Down Expand Up @@ -210,3 +211,14 @@ def responder(environ, start_response):
return [f.read()]

return responder


def authorization_response():
def responder(environ, start_response):
start_response(
"401 Unauthorized", [
("WWW-Authenticate", "Basic"),
],
)

return responder