Skip to content

Commit

Permalink
Update test_invalid_version to expect failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jan 14, 2023
1 parent 310a41c commit 0a6cd4f
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions setuptools/tests/test_dist_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@ def test_conditional_dependencies(self, metadata):
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 = """
Expand Down Expand Up @@ -190,7 +193,17 @@ def test_dist_info_is_the_same_as_in_wheel(
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

0 comments on commit 0a6cd4f

Please sign in to comment.