Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests: more non-PyPI tests
  • Loading branch information
woodruffw committed Jan 5, 2024
commit 6e94d200e20f700fa2e905dd32afeb367d321b67
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