Skip to content
Merged
Show file tree
Hide file tree
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
Fix tests for flit
  • Loading branch information
notatallshaw committed Aug 2, 2025
commit 95f685d279473a401314a4b583ebbcf6ce4720af
41 changes: 18 additions & 23 deletions tests/functional/test_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,38 +99,33 @@ def test_freeze_with_pip(script: PipTestEnvironment) -> None:

def test_freeze_with_setuptools(script: PipTestEnvironment) -> None:
"""
Test that pip shows setuptools only when --all is used
or _should_suppress_build_backends() returns false
Test that pip shows setuptools only when --all is used on Python < 3.12,
otherwise it should be shown in default freeze output.
"""

result = script.pip("freeze", "--all")
assert "setuptools==" in result.stdout

(script.site_packages_path / "mock.pth").write_text("import mock\n")

(script.site_packages_path / "mock.py").write_text(
textwrap.dedent(
"""\
import pip._internal.commands.freeze as freeze
freeze._should_suppress_build_backends = lambda: False
"""
)
)

# Test the default behavior (without --all)
result = script.pip("freeze")
assert "setuptools==" in result.stdout

(script.site_packages_path / "mock.py").write_text(
textwrap.dedent(
"""\
import pip._internal.commands.freeze as freeze
freeze._should_suppress_build_backends = lambda: True
"""
should_suppress = sys.version_info < (3, 12)
if should_suppress:
# setuptools should be hidden in default freeze output
assert "setuptools==" not in result.stdout, (
f"setuptools should be suppressed in Python {sys.version_info[:2]} "
f"but was found in freeze output: {result.stdout}"
)
else:
# setuptools should be shown in default freeze output
assert "setuptools==" in result.stdout, (
f"setuptools should be shown in Python {sys.version_info[:2]} "
f"but was not found in freeze output: {result.stdout}"
)
)

result = script.pip("freeze")
assert "setuptools==" not in result.stdout
# --all should always show setuptools regardless of version
result_all = script.pip("freeze", "--all")
assert "setuptools==" in result_all.stdout


def test_exclude_and_normalization(script: PipTestEnvironment, tmpdir: Path) -> None:
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/test_self_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ def test_self_update_editable(script: Any, pip_src: Any) -> None:
# mode, that pip can safely update itself to an editable install.
# See https://github.com/pypa/pip/issues/12666 for details.

# Install flit-core (build backend) since we use --no-build-isolation
script.pip("install", "flit-core")

# Step 1. Install pip as non-editable. This is expected to succeed as
# the existing pip in the environment is installed in editable mode, so
# it only places a .pth file in the environment.
Expand Down