Skip to content

Commit ea8d010

Browse files
committed
Import repository constants from utils; use them in 410 check; update test name and override comment
Signed-off-by: Aditya Saky <[email protected]>
1 parent ec53ae8 commit ea8d010

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

tests/test_upload.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from twine.commands import upload
1919
from twine import package, cli, exceptions
2020
import twine
21+
from twine.utils import DEFAULT_REPOSITORY, TEST_REPOSITORY
2122

2223
import helpers
2324

@@ -27,8 +28,6 @@
2728
NEW_SDIST_FIXTURE = 'tests/fixtures/twine-1.6.5.tar.gz'
2829
NEW_WHEEL_FIXTURE = 'tests/fixtures/twine-1.6.5-py2.py3-none-any.whl'
2930
NEW_RELEASE_URL = 'https://pypi.org/project/twine/1.6.5/'
30-
DEFAULT_REPOSITORY = "https://upload.pypi.org/legacy/"
31-
TEST_REPOSITORY = "https://test.pypi.org/legacy/"
3231

3332

3433
def test_successful_upload(make_settings, capsys):
@@ -289,10 +288,10 @@ def none_upload(*args, **settings_kwargs):
289288
assert "/foo/bar.crt" == upload_settings.cacert
290289

291290

292-
def test_check_status_code(make_settings, capsys):
291+
def test_check_status_code_for_wrong_repo_url(make_settings, capsys):
293292
upload_settings = make_settings()
294293

295-
# override default upload_settings
294+
# override defaults to use incorrect URL
296295
upload_settings.repository_config['repository'] = \
297296
"https://upload.pypi.org"
298297

twine/commands/upload.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@
1818
from twine.package import PackageFile
1919
from twine import exceptions
2020
from twine import settings
21+
from twine.utils import DEFAULT_REPOSITORY, TEST_REPOSITORY
2122

2223
from requests.exceptions import HTTPError
2324

2425

25-
DEFAULT_REPOSITORY = "https://upload.pypi.org/legacy/"
26-
TEST_REPOSITORY = "https://test.pypi.org/legacy/"
27-
28-
2926
def skip_upload(response, skip_existing, package):
3027
filename = package.basefilename
3128
msg_400 = (
@@ -67,8 +64,8 @@ def check_status_code(response, verbose):
6764
"testpypi.python.org). You've received a 410 error response. "
6865
"Uploading to those sites is deprecated. The new sites are "
6966
"pypi.org and test.pypi.org. Try using "
70-
"https://upload.pypi.org/legacy/ "
71-
"(or https://test.pypi.org/legacy/) to upload your packages "
67+
f"{DEFAULT_REPOSITORY} "
68+
f"(or {TEST_REPOSITORY}) to upload your packages "
7269
"instead. These are the default URLs for Twine now. More at "
7370
"https://packaging.python.org/guides/migrating-to-pypi-org/ ")
7471
elif response.status_code == 405 and "pypi.org" in response.url:

0 commit comments

Comments
 (0)