Skip to content

Commit 0a6cd4f

Browse files
committed
Update test_invalid_version to expect failure.
1 parent 310a41c commit 0a6cd4f

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

setuptools/tests/test_dist_info.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,16 @@ def test_conditional_dependencies(self, metadata):
8282
assert d.extras == ['baz']
8383

8484
def test_invalid_version(self, tmp_path):
85+
"""
86+
Supplying an invalid version crashes dist_info.
87+
"""
8588
config = "[metadata]\nname=proj\nversion=42\n[egg_info]\ntag_build=invalid!!!\n"
8689
(tmp_path / "setup.cfg").write_text(config, encoding="utf-8")
8790
msg = re.compile("invalid version", re.M | re.I)
88-
output = run_command("dist_info", cwd=tmp_path)
89-
assert msg.search(output)
90-
dist_info = next(tmp_path.glob("*.dist-info"))
91-
assert dist_info.name.startswith("proj-42")
91+
proc = run_command_inner("dist_info", cwd=tmp_path, check=False)
92+
assert proc.returncode
93+
assert msg.search(proc.stdout)
94+
assert not list(tmp_path.glob("*.dist-info"))
9295

9396
def test_tag_arguments(self, tmp_path):
9497
config = """
@@ -190,7 +193,17 @@ def test_dist_info_is_the_same_as_in_wheel(
190193
assert read(dist_info / file) == read(wheel_dist_info / file)
191194

192195

193-
def run_command(*cmd, **kwargs):
194-
opts = {"stderr": subprocess.STDOUT, "text": True, **kwargs}
196+
def run_command_inner(*cmd, **kwargs):
197+
opts = {
198+
"stderr": subprocess.STDOUT,
199+
"stdout": subprocess.PIPE,
200+
"text": True,
201+
'check': True,
202+
**kwargs,
203+
}
195204
cmd = [sys.executable, "-c", "__import__('setuptools').setup()", *map(str, cmd)]
196-
return subprocess.check_output(cmd, **opts)
205+
return subprocess.run(cmd, **opts)
206+
207+
208+
def run_command(*args, **kwargs):
209+
return run_command_inner(*args, **kwargs).stdout

0 commit comments

Comments
 (0)