Merge ~wesley-wiedenmeier/cloud-init:integration-testing-mro into cloud-init:master

Proposed by Wesley Wiedenmeier on 2017-03-17
Status: Merged
Merged at revision: 3ec116a1bb3646c2ff932bed24b4bf087b51cb8c
Proposed branch: ~wesley-wiedenmeier/cloud-init:integration-testing-mro
Merge into: cloud-init:master
Diff against target: 11 lines (+1/-1)
1 file modified
tests/cloud_tests/testcases/__init__.py (+1/-1)
Reviewer Review Type Date Requested Status
cloud-init commiters 2017-03-17 Pending
Review via email: mp+320234@code.launchpad.net

Description of the Change

Integration Testing: improve testcase subclassing

Use inspect.getmro(mod) rather than mod.__bases__ to test if a potential
testcase class inherits from CloudTestCase. This allows testcases to be based on CloudTestCase indirectly, adding greater flexibility to the structure of test classes.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/cloud_tests/testcases/__init__.py b/tests/cloud_tests/testcases/__init__.py
2index 182c090..a1d86d4 100644
3--- a/tests/cloud_tests/testcases/__init__.py
4+++ b/tests/cloud_tests/testcases/__init__.py
5@@ -21,7 +21,7 @@ def discover_tests(test_name):
6 raise ValueError('no test verifier found at: {}'.format(testmod_name))
7
8 return [mod for name, mod in inspect.getmembers(testmod)
9- if inspect.isclass(mod) and base_test in mod.__bases__ and
10+ if inspect.isclass(mod) and base_test in inspect.getmro(mod) and
11 getattr(mod, '__test__', True)]
12
13

Subscribers

People subscribed via source and target branches