diff --git a/tests/test_settings.py b/tests/test_settings.py index 972b8c76..a17ff388 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -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): diff --git a/tests/test_utils.py b/tests/test_utils.py index e6d890eb..d4ba8914 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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( diff --git a/twine/utils.py b/twine/utils.py index 113b427c..14a9e06b 100644 --- a/twine/utils.py +++ b/twine/utils.py @@ -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)