Skip to content

Commit

Permalink
Logged config location (#675)
Browse files Browse the repository at this point in the history
* Logged config location with f-strings

* capsys.disabled erroring/not working

* Fix failing output capture

* Added config location test to test_settings.py

* Removed commented out test

* Update tests/test_settings.py

Co-authored-by: Brian Rutledge <brian@bhrutledge.com>
  • Loading branch information
VikramJayanthi17 and bhrutledge committed Aug 9, 2020
1 parent f14462c commit 62cec5b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
17 changes: 17 additions & 0 deletions tests/test_settings.py
Expand Up @@ -68,6 +68,23 @@ def test_setup_logging(verbose, log_level):
assert logger.level == log_level


@pytest.mark.parametrize(
"verbose", [True, False],
)
def test_print_config_path_if_verbose(tmpdir, capsys, make_settings, verbose):
"""Print 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 == ""


def test_identity_requires_sign():
"""Raise an exception when user provides identity but doesn't require sigining."""
with pytest.raises(exceptions.InvalidSigningConfiguration):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_utils.py
Expand Up @@ -295,9 +295,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

0 comments on commit 62cec5b

Please sign in to comment.