From 62020463269b554f421213c3620156b83cc65282 Mon Sep 17 00:00:00 2001 From: Nell Jerram Date: Tue, 17 Jan 2023 11:20:09 +0000 Subject: [PATCH] Revert to using subunit.run instead of nose2 There seems to be a conflict between nose2's and neutron.test.base's handling of failed tests. They both have non-trivial code for intercepting assertion failures, and when test_dhcp_agent.py fails on this line: # Check DHCP driver was asked to restart. call_driver.assert_called_with('restart', mock.ANY) the result is that we get an exception from nose2's own code about not being able to use `join` with an argument that is not an iterable. Modifying the nose2 code at that point shows this: MODIFIED OUTPUT: test= exctype= value=_StringException(' Empty attachments: stdout Traceback (most recent call last): File "/code/.tox/py38/lib/python3.8/site-packages/neutron/tests/base.py", line 182, in func return f(self, *args, **kwargs) File "/code/networking_calico/tests/test_dhcp_agent.py", line 137, in test_mainline call_driver.assert_called_with(\'restart\', mock.ANY) File "/code/.tox/py38/lib/python3.8/site-packages/mock/mock.py", line 932, in assert_called_with raise AssertionError(error_message) AssertionError: expected call not found. Expected: call_driver(\'restart\', ) Actual: not called. ') tb=None It looks like nose2 expects direct access to the traceback, but neutron.test.base has already reformatted into a string form that nose2 can't handle. When we revert to using subunit.run, we get this useful failure output: FAIL: networking_calico.tests.test_dhcp_agent.TestDhcpAgent.test_mainline tags: worker-0 ---------------------------------------------------------------------- Traceback (most recent call last): File "/code/.tox/py38/lib/python3.8/site-packages/neutron/tests/base.py", line 182, in func return f(self, *args, **kwargs) File "/code/networking_calico/tests/test_dhcp_agent.py", line 137, in test_mainline call_driver.assert_called_with('restart', mock.ANY) File "/code/.tox/py38/lib/python3.8/site-packages/mock/mock.py", line 932, in assert_called_with raise AssertionError(error_message) AssertionError: expected call not found. Expected: call_driver('restart', ) Actual: not called. Obvious question: so why did I recently switch from subunit.run to nose2? I can't remember precisely, but I suspect it was a situation that has now been fixed in the more correct way by imposing all of the Ussuri release's constraints on Python packages. --- networking-calico/.testr.conf | 6 ++---- networking-calico/test-requirements.txt | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/networking-calico/.testr.conf b/networking-calico/.testr.conf index 0ec56a34adc..2a660613816 100644 --- a/networking-calico/.testr.conf +++ b/networking-calico/.testr.conf @@ -3,10 +3,8 @@ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-0} \ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ sh -c '\ - ${PYTHON:-python} -m coverage run -a -m nose2 -v -s networking_calico/tests && \ - ${PYTHON:-python} -m coverage run -a -m nose2 -v networking_calico.plugins.ml2.drivers.calico.test.test_election && \ - ${PYTHON:-python} -m coverage run -a -m nose2 -v networking_calico.plugins.ml2.drivers.calico.test.test_plugin_etcd && \ - ${PYTHON:-python} -m coverage run -a -m nose2 -v networking_calico.plugins.ml2.drivers.calico.test.test_compaction' + ${PYTHON:-python} -m coverage run -a -m subunit.run discover -t . networking_calico/tests $LISTOPT $IDOPTION && \ + ${PYTHON:-python} -m coverage run -a -m subunit.run discover -t . networking_calico/plugins/ml2/drivers/calico/test $LISTOPT $IDOPTION' test_id_option=--load-list $IDFILE test_list_option=--list diff --git a/networking-calico/test-requirements.txt b/networking-calico/test-requirements.txt index 856f9bf630d..ab2c3199b37 100644 --- a/networking-calico/test-requirements.txt +++ b/networking-calico/test-requirements.txt @@ -20,5 +20,3 @@ neutron>=16,<17 neutron-lib==2.3.0 mock>=3.0.0 # BSD pyroute2<0.6.0 # Apache v2 - -nose2