diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2023-01-14 12:41:47 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2023-01-14 12:41:47 -0500 |
| commit | 0a6cd4fc60a5ac61ab8f57a52d171ef4d2837067 (patch) | |
| tree | fdeb3cdb657e5324949b8cef19e01c60010a7e4e /setuptools/tests | |
| parent | 310a41c78bc80da05dbc37cf452a86f48ca55427 (diff) | |
| download | python-setuptools-git-0a6cd4fc60a5ac61ab8f57a52d171ef4d2837067.tar.gz | |
Update test_invalid_version to expect failure.
Diffstat (limited to 'setuptools/tests')
| -rw-r--r-- | setuptools/tests/test_dist_info.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index b83b8021..45b0d7fb 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -82,13 +82,16 @@ class TestDistInfo: assert d.extras == ['baz'] def test_invalid_version(self, tmp_path): + """ + Supplying an invalid version crashes dist_info. + """ config = "[metadata]\nname=proj\nversion=42\n[egg_info]\ntag_build=invalid!!!\n" (tmp_path / "setup.cfg").write_text(config, encoding="utf-8") msg = re.compile("invalid version", re.M | re.I) - output = run_command("dist_info", cwd=tmp_path) - assert msg.search(output) - dist_info = next(tmp_path.glob("*.dist-info")) - assert dist_info.name.startswith("proj-42") + proc = run_command_inner("dist_info", cwd=tmp_path, check=False) + assert proc.returncode + assert msg.search(proc.stdout) + assert not list(tmp_path.glob("*.dist-info")) def test_tag_arguments(self, tmp_path): config = """ @@ -190,7 +193,17 @@ class TestWheelCompatibility: assert read(dist_info / file) == read(wheel_dist_info / file) -def run_command(*cmd, **kwargs): - opts = {"stderr": subprocess.STDOUT, "text": True, **kwargs} +def run_command_inner(*cmd, **kwargs): + opts = { + "stderr": subprocess.STDOUT, + "stdout": subprocess.PIPE, + "text": True, + 'check': True, + **kwargs, + } cmd = [sys.executable, "-c", "__import__('setuptools').setup()", *map(str, cmd)] - return subprocess.check_output(cmd, **opts) + return subprocess.run(cmd, **opts) + + +def run_command(*args, **kwargs): + return run_command_inner(*args, **kwargs).stdout |
