Skip to content

Commit a017005

Browse files
authored
Merge pull request #1188 from pypa/ww/fix-twine-check-glob
check: fix handling of non-shell-expanded globs
2 parents 873f33e + e98f03b commit a017005

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

tests/helpers.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
import pathlib
1919

2020
TESTS_DIR = pathlib.Path(__file__).parent
21-
SDIST_FIXTURE = os.path.join(TESTS_DIR, "fixtures/twine-1.5.0.tar.gz")
22-
WHEEL_FIXTURE = os.path.join(TESTS_DIR, "fixtures/twine-1.5.0-py2.py3-none-any.whl")
23-
NEW_SDIST_FIXTURE = os.path.join(TESTS_DIR, "fixtures/twine-1.6.5.tar.gz")
24-
NEW_WHEEL_FIXTURE = os.path.join(TESTS_DIR, "fixtures/twine-1.6.5-py2.py3-none-any.whl")
21+
FIXTURES_DIR = os.path.join(TESTS_DIR, "fixtures")
22+
SDIST_FIXTURE = os.path.join(FIXTURES_DIR, "twine-1.5.0.tar.gz")
23+
WHEEL_FIXTURE = os.path.join(FIXTURES_DIR, "twine-1.5.0-py2.py3-none-any.whl")
24+
NEW_SDIST_FIXTURE = os.path.join(FIXTURES_DIR, "twine-1.6.5.tar.gz")
25+
NEW_WHEEL_FIXTURE = os.path.join(FIXTURES_DIR, "twine-1.6.5-py2.py3-none-any.whl")
2526

2627

2728
@contextlib.contextmanager

tests/test_check.py

+16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import pretend
1919
import pytest
2020

21+
from tests import helpers
2122
from twine.commands import check
2223

2324

@@ -283,6 +284,21 @@ def test_main(monkeypatch):
283284
assert check_stub.calls == [pretend.call(["dist/*"], strict=False)]
284285

285286

287+
def test_check_expands_glob(monkeypatch):
288+
"""Regression test for #1187."""
289+
warning_stream = pretend.stub()
290+
warning_stream_cls = pretend.call_recorder(lambda: warning_stream)
291+
monkeypatch.setattr(check, "_WarningStream", warning_stream_cls)
292+
293+
check_file = pretend.call_recorder(lambda fn, stream: ([], True))
294+
monkeypatch.setattr(check, "_check_file", check_file)
295+
296+
assert not check.main([f"{helpers.FIXTURES_DIR}/*"])
297+
298+
# check_file is called more than once, indicating the glob has been expanded
299+
assert len(check_file.calls) > 1
300+
301+
286302
# TODO: Test print() color output
287303

288304
# TODO: Test log formatting

twine/commands/check.py

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def check(
127127
:return:
128128
``True`` if there are rendering errors, otherwise ``False``.
129129
"""
130+
dists = commands._find_dists(dists)
130131
uploads, _, _ = commands._split_inputs(dists)
131132
if not uploads: # Return early, if there are no files to check.
132133
logger.error("No files to check.")

0 commit comments

Comments
 (0)