Skip to content

Commit f8e988e

Browse files
committed
Rework test that needed --global-option to use --config-setting
1 parent 3606abb commit f8e988e

File tree

6 files changed

+50
-37
lines changed

6 files changed

+50
-37
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
import sys
3+
4+
from setuptools import build_meta
5+
from setuptools.build_meta import *
6+
7+
8+
def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
9+
if config_settings and "fail" in config_settings:
10+
print("I DIE, I DIE in prepare_metadata_for_build_wheel")
11+
sys.exit(1)
12+
print("HELLO FROM CHATTYMODULE prepare_metadata_for_build_wheel")
13+
return build_meta.prepare_metadata_for_build_wheel(
14+
metadata_directory, config_settings
15+
)
16+
17+
18+
def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
19+
if config_settings and "fail" in config_settings:
20+
print("I DIE, I DIE in build_wheel")
21+
sys.exit(1)
22+
print("HELLO FROM CHATTYMODULE build_wheel")
23+
return build_meta.build_wheel(wheel_directory, config_settings, metadata_directory)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "backend"
4+
backend-path = ["."]
5+
6+
[project]
7+
name = "chattymodule"
8+
version = "0.0.1"
9+
10+
[tool.setuptools]
11+
py-modules = ["chattymodule"]

tests/data/src/chattymodule/setup.cfg

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/data/src/chattymodule/setup.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/functional/test_install.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,12 @@ def test_install_upgrade_editable_depending_on_other_editable(
16131613
def test_install_subprocess_output_handling(
16141614
script: PipTestEnvironment, data: TestData
16151615
) -> None:
1616-
args = ["install", os.fspath(data.src.joinpath("chattymodule"))]
1616+
args = [
1617+
"install",
1618+
"--no-build-isolation",
1619+
"--no-cache",
1620+
os.fspath(data.src.joinpath("chattymodule")),
1621+
]
16171622

16181623
# Regular install should not show output from the chatty setup.py
16191624
result = script.pip(*args)
@@ -1624,21 +1629,23 @@ def test_install_subprocess_output_handling(
16241629
# Only count examples with sys.argv[1] == egg_info, because we call
16251630
# setup.py multiple times, which should not count as duplicate output.
16261631
result = script.pip(*(args + ["--verbose"]), expect_stderr=True)
1627-
assert 1 == result.stderr.count("HELLO FROM CHATTYMODULE egg_info")
1632+
assert 1 == result.stderr.count(
1633+
"HELLO FROM CHATTYMODULE prepare_metadata_for_build_wheel"
1634+
)
1635+
assert 1 == result.stderr.count("HELLO FROM CHATTYMODULE build_wheel")
16281636
script.pip("uninstall", "-y", "chattymodule")
16291637

16301638
# If the install fails, then we *should* show the output... but only once,
16311639
# even if --verbose is given.
1632-
result = script.pip(*(args + ["--global-option=--fail"]), expect_error=True)
1633-
# This error is emitted 3 times:
1634-
# - by setup.py bdist_wheel
1635-
# - by setup.py clean
1636-
assert 2 == result.stderr.count("I DIE, I DIE")
1640+
result = script.pip(*(args + ["--config-setting=fail=1"]), expect_error=True)
1641+
assert 1 == result.stderr.count("I DIE, I DIE")
1642+
assert 1 == result.stderr.count("I DIE, I DIE in prepare_metadata_for_build_wheel")
16371643

16381644
result = script.pip(
1639-
*(args + ["--global-option=--fail", "--verbose"]), expect_error=True
1645+
*(args + ["--config-setting=fail=1", "--verbose"]), expect_error=True
16401646
)
1641-
assert 2 == result.stderr.count("I DIE, I DIE")
1647+
assert 1 == result.stderr.count("I DIE, I DIE")
1648+
assert 1 == result.stderr.count("I DIE, I DIE in prepare_metadata_for_build_wheel")
16421649

16431650

16441651
def test_install_log(script: PipTestEnvironment, data: TestData, tmpdir: Path) -> None:

tests/functional/test_install_vcs_git.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ def test_git_with_non_editable_unpacking(
373373
)
374374
result = script.pip(
375375
"install",
376-
"--global-option=--quiet",
377376
local_url,
378377
allow_stderr_warning=True,
379378
)

0 commit comments

Comments
 (0)