_TRUE_VALUES = ('True', 'true', '1', 'yes') CELL1_NAME = 'cell1' # For compatibility with the large number of tests which use test.nested nested = utils.nested_contexts class TestingException(Exception): pass # NOTE(claudiub): this needs to be called before any mock.patch calls are # being done, and especially before any other test classes load. This fixes # the mock.patch autospec issue: # https://github.com/testing-cabal/mock/issues/396 mock_fixture.patch_mock_module() def _poison_unfair_compute_resource_semaphore_locking(): """Ensure that every locking on COMPUTE_RESOURCE_SEMAPHORE is called with fair=True. """ orig_synchronized = utils.synchronized def poisoned_synchronized(*args, **kwargs): # Only check fairness if the decorator is used with # COMPUTE_RESOURCE_SEMAPHORE. But the name of the semaphore can be # passed as args or as kwargs. # Note that we cannot import COMPUTE_RESOURCE_SEMAPHORE as that would # apply the decorators we want to poison here. if len(args) >= 1:
% name) return wrapped(_self, name) return wrapper mock.Mock.__getattr__ = raise_for_invalid_assert_calls( mock.Mock.__getattr__) # NOTE(gibi): needs to be called only once at import time # to patch the mock lib _patch_mock_to_raise_for_invalid_assert_calls() # NOTE(claudiub): this needs to be called before any mock.patch calls are # being done, and especially before any other test classes load. This fixes # the mock.patch autospec issue: # https://github.com/testing-cabal/mock/issues/396 mock_fixture.patch_mock_module() class NoDBTestCase(testtools.TestCase): """Test case base class for all unit tests. Due to the slowness of DB access, please consider deriving from `NoDBTestCase` first. """ TIMEOUT_SCALING_FACTOR = 1 def setUp(self): """Run before each test method to initialize test environment.""" super(NoDBTestCase, self).setUp() self.useFixture(mock_fixture.MockAutospecFixture())