Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check: fix handling of non-shell-expanded globs #1188

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading