@@ -99,38 +99,33 @@ def test_freeze_with_pip(script: PipTestEnvironment) -> None:
99
99
100
100
def test_freeze_with_setuptools (script : PipTestEnvironment ) -> None :
101
101
"""
102
- Test that pip shows setuptools only when --all is used
103
- or _should_suppress_build_backends() returns false
102
+ Test that pip shows setuptools only when --all is used on Python < 3.12,
103
+ otherwise it should be shown in default freeze output.
104
104
"""
105
105
106
106
result = script .pip ("freeze" , "--all" )
107
107
assert "setuptools==" in result .stdout
108
108
109
- (script .site_packages_path / "mock.pth" ).write_text ("import mock\n " )
110
-
111
- (script .site_packages_path / "mock.py" ).write_text (
112
- textwrap .dedent (
113
- """\
114
- import pip._internal.commands.freeze as freeze
115
- freeze._should_suppress_build_backends = lambda: False
116
- """
117
- )
118
- )
119
-
109
+ # Test the default behavior (without --all)
120
110
result = script .pip ("freeze" )
121
- assert "setuptools==" in result .stdout
122
111
123
- (script .site_packages_path / "mock.py" ).write_text (
124
- textwrap .dedent (
125
- """\
126
- import pip._internal.commands.freeze as freeze
127
- freeze._should_suppress_build_backends = lambda: True
128
- """
112
+ should_suppress = sys .version_info < (3 , 12 )
113
+ if should_suppress :
114
+ # setuptools should be hidden in default freeze output
115
+ assert "setuptools==" not in result .stdout , (
116
+ f"setuptools should be suppressed in Python { sys .version_info [:2 ]} "
117
+ f"but was found in freeze output: { result .stdout } "
118
+ )
119
+ else :
120
+ # setuptools should be shown in default freeze output
121
+ assert "setuptools==" in result .stdout , (
122
+ f"setuptools should be shown in Python { sys .version_info [:2 ]} "
123
+ f"but was not found in freeze output: { result .stdout } "
129
124
)
130
- )
131
125
132
- result = script .pip ("freeze" )
133
- assert "setuptools==" not in result .stdout
126
+ # --all should always show setuptools regardless of version
127
+ result_all = script .pip ("freeze" , "--all" )
128
+ assert "setuptools==" in result_all .stdout
134
129
135
130
136
131
def test_exclude_and_normalization (script : PipTestEnvironment , tmpdir : Path ) -> None :
0 commit comments