Skip to content

Commit

Permalink
tests: more non-PyPI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
woodruffw committed Jan 5, 2024
1 parent e912312 commit 6e94d20
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,13 +544,16 @@ def test_skip_upload_respects_skip_existing():
)


def test_values_from_env(monkeypatch):
@pytest.mark.parametrize("repo", ["pypi", "testpypi"])
def test_values_from_env_pypi(monkeypatch, repo):
def none_upload(*args, **settings_kwargs):
pass

replaced_upload = pretend.call_recorder(none_upload)
monkeypatch.setattr(upload, "upload", replaced_upload)
testenv = {
"TWINE_REPOSITORY": repo,
# Ignored because TWINE_REPOSITORY is PyPI/TestPyPI
"TWINE_USERNAME": "this-is-ignored",
"TWINE_PASSWORD": "pypipassword",
"TWINE_CERT": "/foo/bar.crt",
Expand All @@ -563,6 +566,39 @@ def none_upload(*args, **settings_kwargs):
assert "/foo/bar.crt" == upload_settings.cacert


def test_values_from_env_non_pypi(monkeypatch, write_config_file):
write_config_file(
"""
[distutils]
index-servers =
notpypi
[notpypi]
repository: https://upload.example.org/legacy/
username:someusername
password:password
"""
)

def none_upload(*args, **settings_kwargs):
pass

replaced_upload = pretend.call_recorder(none_upload)
monkeypatch.setattr(upload, "upload", replaced_upload)
testenv = {
"TWINE_REPOSITORY": "notpypi",
"TWINE_USERNAME": "someusername",
"TWINE_PASSWORD": "pypipassword",
"TWINE_CERT": "/foo/bar.crt",
}
with helpers.set_env(**testenv):
cli.dispatch(["upload", "path/to/file"])
upload_settings = replaced_upload.calls[0].args[0]
assert "pypipassword" == upload_settings.password
assert "someusername" == upload_settings.username
assert "/foo/bar.crt" == upload_settings.cacert


@pytest.mark.parametrize(
"repo_url",
["https://upload.pypi.org/", "https://test.pypi.org/", "https://pypi.org/"],
Expand Down

0 comments on commit 6e94d20

Please sign in to comment.