Commit 8b8e2c8b authored by Paul Ganssle's avatar Paul Ganssle

Change how license field ValueError is tested

Both the old and new approaches are deeply unsatisfying to me, but
without reworking how these test commands are run, I think this is
about as close as we can get to enforcing that this specific call
raises ValueError.
parent 2b038993
......@@ -165,9 +165,20 @@ class TestEggInfo:
build_files({'setup.py': setup_script,
'setup.cfg': setup_config})
with pytest.raises(ValueError):
# This command should fail with a ValueError, but because it's
# currently configured to use a subprocess, the actual traceback
# object is lost and we need to parse it from stderr
with pytest.raises(AssertionError) as exc:
self._run_egg_info_command(tmpdir_cwd, env)
# Hopefully this is not too fragile: the only argument to the
# assertion error should be a traceback, ending with:
# ValueError: ....
#
# assert not 1
tb = exc.value.args[0].split('\n')
assert tb[-3].lstrip().startswith('ValueError')
def test_rebuilt(self, tmpdir_cwd, env):
"""Ensure timestamps are updated when the command is re-run."""
self._create_project()
......@@ -617,11 +628,8 @@ class TestEggInfo:
data_stream=1,
env=environ,
)
if code:
if 'ValueError' in data:
raise ValueError(data)
else:
raise AssertionError(data)
assert not code, data
if output:
assert output in data
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment