From bfab7dad351f4b701e98b1235524e59bb2ab5a36 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Fri, 21 Nov 2014 12:23:31 -0800 Subject: [PATCH] Fix test discovery by new testtools New testtools finds tests in tests/__init__.py and attempts to execute them. Stop this from happening by not inheriting from the base test class in __init__.py. Instead mix in the base test class where we actually need to run the tests in test_allocator.py Change-Id: I9733ac407d415c90e7dcaa2c6e6a972e75ce6d42 --- nodepool/tests/__init__.py | 4 ++-- nodepool/tests/test_allocator.py | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/nodepool/tests/__init__.py b/nodepool/tests/__init__.py index 1b36cb19e..6e5061f27 100644 --- a/nodepool/tests/__init__.py +++ b/nodepool/tests/__init__.py @@ -58,7 +58,7 @@ class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase): self.useFixture(fixtures.NestedTempfile()) -class AllocatorTestCase(BaseTestCase): +class AllocatorTestCase(object): def setUp(self): super(AllocatorTestCase, self).setUp() self.agt = [] @@ -74,7 +74,7 @@ class AllocatorTestCase(BaseTestCase): for x in self.agt])) -class RoundRobinTestCase(BaseTestCase): +class RoundRobinTestCase(object): def setUp(self): super(RoundRobinTestCase, self).setUp() self.allocations = [] diff --git a/nodepool/tests/test_allocator.py b/nodepool/tests/test_allocator.py index 454d48d38..cdcdc408b 100644 --- a/nodepool/tests/test_allocator.py +++ b/nodepool/tests/test_allocator.py @@ -19,7 +19,7 @@ from nodepool import tests from nodepool import allocation -class OneLabel(tests.AllocatorTestCase): +class OneLabel(tests.AllocatorTestCase, tests.BaseTestCase): """The simplest case: one each of providers, labels, and targets. @@ -44,7 +44,7 @@ class OneLabel(tests.AllocatorTestCase): ap1.makeGrants() -class TwoLabels(tests.AllocatorTestCase): +class TwoLabels(tests.AllocatorTestCase, tests.BaseTestCase): """Two labels from one provider. Result AGTs are: @@ -72,7 +72,7 @@ class TwoLabels(tests.AllocatorTestCase): ap1.makeGrants() -class TwoProvidersTwoLabels(tests.AllocatorTestCase): +class TwoProvidersTwoLabels(tests.AllocatorTestCase, tests.BaseTestCase): """Two labels, each of which is supplied by both providers. Result AGTs are: @@ -123,7 +123,8 @@ class TwoProvidersTwoLabels(tests.AllocatorTestCase): ap2.makeGrants() -class TwoProvidersTwoLabelsOneShared(tests.AllocatorTestCase): +class TwoProvidersTwoLabelsOneShared(tests.AllocatorTestCase, + tests.BaseTestCase): """One label is served by both providers, the other can only come from one. This tests that the allocator uses the diverse provider to supply the label that can come from either while reserving @@ -176,7 +177,7 @@ class TwoProvidersTwoLabelsOneShared(tests.AllocatorTestCase): ap2.makeGrants() -class RoundRobinAllocation(tests.RoundRobinTestCase): +class RoundRobinAllocation(tests.RoundRobinTestCase, tests.BaseTestCase): """Test the round-robin behaviour of the AllocationHistory object to ensure fairness of distribution @@ -310,7 +311,7 @@ class RoundRobinAllocation(tests.RoundRobinTestCase): do_it() -class RoundRobinFixedProvider(tests.RoundRobinTestCase): +class RoundRobinFixedProvider(tests.RoundRobinTestCase, tests.BaseTestCase): """Test that round-robin behaviour exists when we have a more complex situation where some nodes can only be provided by some providers