Skip to content

Commit

Permalink
check: fix handling of non-shell-expanded globs
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw committed Nov 30, 2024
1 parent 873f33e commit e98f03b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
import pathlib

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


@contextlib.contextmanager
Expand Down
16 changes: 16 additions & 0 deletions tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import pretend
import pytest

from tests import helpers
from twine.commands import check


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


def test_check_expands_glob(monkeypatch):
"""Regression test for #1187."""
warning_stream = pretend.stub()
warning_stream_cls = pretend.call_recorder(lambda: warning_stream)
monkeypatch.setattr(check, "_WarningStream", warning_stream_cls)

check_file = pretend.call_recorder(lambda fn, stream: ([], True))
monkeypatch.setattr(check, "_check_file", check_file)

assert not check.main([f"{helpers.FIXTURES_DIR}/*"])

# check_file is called more than once, indicating the glob has been expanded
assert len(check_file.calls) > 1


# TODO: Test print() color output

# TODO: Test log formatting
1 change: 1 addition & 0 deletions twine/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def check(
:return:
``True`` if there are rendering errors, otherwise ``False``.
"""
dists = commands._find_dists(dists)
uploads, _, _ = commands._split_inputs(dists)
if not uploads: # Return early, if there are no files to check.
logger.error("No files to check.")
Expand Down

0 comments on commit e98f03b

Please sign in to comment.