@@ -544,13 +544,16 @@ def test_skip_upload_respects_skip_existing():
544544 )
545545
546546
547- def test_values_from_env (monkeypatch ):
547+ @pytest .mark .parametrize ("repo" , ["pypi" , "testpypi" ])
548+ def test_values_from_env_pypi (monkeypatch , repo ):
548549 def none_upload (* args , ** settings_kwargs ):
549550 pass
550551
551552 replaced_upload = pretend .call_recorder (none_upload )
552553 monkeypatch .setattr (upload , "upload" , replaced_upload )
553554 testenv = {
555+ "TWINE_REPOSITORY" : repo ,
556+ # Ignored because TWINE_REPOSITORY is PyPI/TestPyPI
554557 "TWINE_USERNAME" : "this-is-ignored" ,
555558 "TWINE_PASSWORD" : "pypipassword" ,
556559 "TWINE_CERT" : "/foo/bar.crt" ,
@@ -563,6 +566,39 @@ def none_upload(*args, **settings_kwargs):
563566 assert "/foo/bar.crt" == upload_settings .cacert
564567
565568
569+ def test_values_from_env_non_pypi (monkeypatch , write_config_file ):
570+ write_config_file (
571+ """
572+ [distutils]
573+ index-servers =
574+ notpypi
575+
576+ [notpypi]
577+ repository: https://upload.example.org/legacy/
578+ username:someusername
579+ password:password
580+ """
581+ )
582+
583+ def none_upload (* args , ** settings_kwargs ):
584+ pass
585+
586+ replaced_upload = pretend .call_recorder (none_upload )
587+ monkeypatch .setattr (upload , "upload" , replaced_upload )
588+ testenv = {
589+ "TWINE_REPOSITORY" : "notpypi" ,
590+ "TWINE_USERNAME" : "someusername" ,
591+ "TWINE_PASSWORD" : "pypipassword" ,
592+ "TWINE_CERT" : "/foo/bar.crt" ,
593+ }
594+ with helpers .set_env (** testenv ):
595+ cli .dispatch (["upload" , "path/to/file" ])
596+ upload_settings = replaced_upload .calls [0 ].args [0 ]
597+ assert "pypipassword" == upload_settings .password
598+ assert "someusername" == upload_settings .username
599+ assert "/foo/bar.crt" == upload_settings .cacert
600+
601+
566602@pytest .mark .parametrize (
567603 "repo_url" ,
568604 ["https://upload.pypi.org/" , "https://test.pypi.org/" , "https://pypi.org/" ],
0 commit comments