Find some way to make subtests work

Bug #1445552 reported by Brian Curtin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack SDK
Confirmed
Wishlist
Unassigned

Bug Description

If TestCase.subTest worked properly in all of our test dependencies, we would have much less duplication. Currently, coverage of delete tests requires two tests per delete call that flip a bool, which would be better off as one test that generated subtests for True/False. If the following diff worked, we'd be better off. There's something off in the versions of unittest2, subunit, and perhaps others, that are not allowing this to work. It's a Python 3.4 feature that was backported and apparently works differently with our test runner infrastructure.

Tags: testing
Revision history for this message
Brian Curtin (brian.curtin) wrote :

diff --git a/openstack/tests/unit/test_proxy_base.py b/openstack/tests/unit/test_proxy_base.py
index e315a7d..10b2e94 100644
--- a/openstack/tests/unit/test_proxy_base.py
+++ b/openstack/tests/unit/test_proxy_base.py
@@ -76,12 +76,14 @@ class TestProxyBase(base.TestCase):
     def verify_delete(self, mock_method, test_method, **kwargs):
         self._verify(mock_method, test_method, **kwargs)

- def verify_delete2(self, resource, method, ignore):
- self._verify2('openstack.proxy.BaseProxy._delete',
- method,
- method_args=["resource_or_id"],
- method_kwargs={"ignore_missing": ignore},
- expected_args=[resource, "resource_or_id", ignore])
+ def verify_delete2(self, resource, method):
+ for ignore in (True, False):
+ with self.subTest(ignore=ignore):
+ self._verify2('openstack.proxy.BaseProxy._delete', method,
+ method_args=["resource_or_id"],
+ method_kwargs={"ignore_missing": ignore},
+ expected_args=[resource, "resource_or_id",
+ ignore])

     def verify_get(self, mock_method, test_method, **kwargs):
         self._verify(mock_method, test_method, expected_result="result",

description: updated
Revision history for this message
Brian Curtin (brian.curtin) wrote :

Formatting came out weird. http://paste.openstack.org/show/204481/

Changed in python-openstacksdk:
status: New → Confirmed
importance: Undecided → Wishlist
milestone: none → 1.0
tags: added: testing
Changed in python-openstacksdk:
milestone: 1.0 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.