From 8b8e2c8b3b83151dad1719a8cb676e919766c1c9 Mon Sep 17 00:00:00 2001 From: Paul Ganssle Date: Sat, 29 Dec 2018 10:53:13 -0500 Subject: 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. --- setuptools/tests/test_egg_info.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index e1105044..979ff18e 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -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 -- cgit v1.2.3