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

Logged config location #675

Merged
merged 6 commits into from Aug 9, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 18 additions & 2 deletions tests/test_utils.py
Expand Up @@ -51,6 +51,22 @@ def test_get_config(tmpdir):
}


@pytest.mark.parametrize(
"verbose", [True, False],
)
def test_get_config_log_location(tmpdir, capsys, make_settings, verbose):
"""Log the location of the .pypirc config used by the user."""
pypirc = os.path.join(str(tmpdir), ".pypirc")

make_settings(verbose=verbose)

captured = capsys.readouterr()
if verbose:
assert captured.out == f"Using configuration from {pypirc}\n"
else:
assert captured.out == ""
bhrutledge marked this conversation as resolved.
Show resolved Hide resolved


def test_get_config_no_distutils(tmpdir):
"""Upload by default to PyPI if an index server is not set in .pypirc."""
pypirc = os.path.join(str(tmpdir), ".pypirc")
Expand Down Expand Up @@ -295,9 +311,9 @@ def test_check_status_code_for_missing_status_code(
captured = capsys.readouterr()

if verbose:
assert captured.out == "Content received from server:\nForbidden\n"
assert captured.out.count("Content received from server:\nForbidden\n") == 1
else:
assert captured.out == "NOTE: Try --verbose to see response content.\n"
assert captured.out.count("NOTE: Try --verbose to see response content.\n") == 1


@pytest.mark.parametrize(
Expand Down
2 changes: 2 additions & 0 deletions twine/utils.py
Expand Up @@ -64,6 +64,8 @@ def get_config(path: str = "~/.pypirc") -> Dict[str, RepositoryConfig]:
# Expand user strings in the path
path = os.path.expanduser(path)

logger.info(f"Using configuration from {path}")

# Parse the rc file
if os.path.isfile(path):
parser.read(path)
Expand Down