@@ -544,13 +544,16 @@ def test_skip_upload_respects_skip_existing():
544
544
)
545
545
546
546
547
- def test_values_from_env (monkeypatch ):
547
+ @pytest .mark .parametrize ("repo" , ["pypi" , "testpypi" ])
548
+ def test_values_from_env_pypi (monkeypatch , repo ):
548
549
def none_upload (* args , ** settings_kwargs ):
549
550
pass
550
551
551
552
replaced_upload = pretend .call_recorder (none_upload )
552
553
monkeypatch .setattr (upload , "upload" , replaced_upload )
553
554
testenv = {
555
+ "TWINE_REPOSITORY" : repo ,
556
+ # Ignored because TWINE_REPOSITORY is PyPI/TestPyPI
554
557
"TWINE_USERNAME" : "this-is-ignored" ,
555
558
"TWINE_PASSWORD" : "pypipassword" ,
556
559
"TWINE_CERT" : "/foo/bar.crt" ,
@@ -563,6 +566,39 @@ def none_upload(*args, **settings_kwargs):
563
566
assert "/foo/bar.crt" == upload_settings .cacert
564
567
565
568
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
+
566
602
@pytest .mark .parametrize (
567
603
"repo_url" ,
568
604
["https://upload.pypi.org/" , "https://test.pypi.org/" , "https://pypi.org/" ],
0 commit comments