Skip to content

Commit 9eeaa9e

Browse files
committed
Rework test that needed --global-option to use --config-setting
1 parent 08fd1e9 commit 9eeaa9e

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
@@ -1618,7 +1618,12 @@ def test_install_upgrade_editable_depending_on_other_editable(
16181618
def test_install_subprocess_output_handling(
16191619
script: PipTestEnvironment, data: TestData
16201620
) -> None:
1621-
args = ["install", os.fspath(data.src.joinpath("chattymodule"))]
1621+
args = [
1622+
"install",
1623+
"--no-build-isolation",
1624+
"--no-cache",
1625+
os.fspath(data.src.joinpath("chattymodule")),
1626+
]
16221627

16231628
# Regular install should not show output from the chatty setup.py
16241629
result = script.pip(*args)
@@ -1629,21 +1634,23 @@ def test_install_subprocess_output_handling(
16291634
# Only count examples with sys.argv[1] == egg_info, because we call
16301635
# setup.py multiple times, which should not count as duplicate output.
16311636
result = script.pip(*(args + ["--verbose"]), expect_stderr=True)
1632-
assert 1 == result.stderr.count("HELLO FROM CHATTYMODULE egg_info")
1637+
assert 1 == result.stderr.count(
1638+
"HELLO FROM CHATTYMODULE prepare_metadata_for_build_wheel"
1639+
)
1640+
assert 1 == result.stderr.count("HELLO FROM CHATTYMODULE build_wheel")
16331641
script.pip("uninstall", "-y", "chattymodule")
16341642

16351643
# If the install fails, then we *should* show the output... but only once,
16361644
# even if --verbose is given.
1637-
result = script.pip(*(args + ["--global-option=--fail"]), expect_error=True)
1638-
# This error is emitted 3 times:
1639-
# - by setup.py bdist_wheel
1640-
# - by setup.py clean
1641-
assert 2 == result.stderr.count("I DIE, I DIE")
1645+
result = script.pip(*(args + ["--config-setting=fail=1"]), expect_error=True)
1646+
assert 1 == result.stderr.count("I DIE, I DIE")
1647+
assert 1 == result.stderr.count("I DIE, I DIE in prepare_metadata_for_build_wheel")
16421648

16431649
result = script.pip(
1644-
*(args + ["--global-option=--fail", "--verbose"]), expect_error=True
1650+
*(args + ["--config-setting=fail=1", "--verbose"]), expect_error=True
16451651
)
1646-
assert 2 == result.stderr.count("I DIE, I DIE")
1652+
assert 1 == result.stderr.count("I DIE, I DIE")
1653+
assert 1 == result.stderr.count("I DIE, I DIE in prepare_metadata_for_build_wheel")
16471654

16481655

16491656
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)