def _flatten_tests(suite_or_case, unpack_outer=False): try: tests = iter(suite_or_case) except TypeError: # Not iterable, assume it's a test case. return [(suite_or_case.id(), suite_or_case)] if (type(suite_or_case) in (unittest.TestSuite,) or unpack_outer): # Plain old test suite (or any others we may add). result = [] for test in tests: # Recurse to flatten. result.extend(_flatten_tests(test)) return result else: # Find any old actual test and grab its id. suite_id = None tests = iterate_tests(suite_or_case) for test in tests: suite_id = test.id() break # If it has a sort_tests method, call that. if safe_hasattr(suite_or_case, 'sort_tests'): suite_or_case.sort_tests() return [(suite_id, suite_or_case)]
def test_tacker_command_meta_defines_log(self): class FakeCommand(tackerV10.TackerCommand): pass self.assertTrue(helpers.safe_hasattr(FakeCommand, 'log')) self.assertIsInstance(FakeCommand.log, logging.getLoggerClass()) self.assertEqual(FakeCommand.log.name, __name__ + ".FakeCommand")
def test_neutron_command_meta_defines_log(self): class FakeCommand(neutronV20.NeutronCommand): pass self.assertTrue(helpers.safe_hasattr(FakeCommand, 'log')) self.assertIsInstance(FakeCommand.log, logging.getLoggerClass()) self.assertEqual(__name__ + ".FakeCommand", FakeCommand.log.name)
def _flatten_tests(suite_or_case, unpack_outer=False): try: tests = iter(suite_or_case) except TypeError: # Not iterable, assume it's a test case. return [(suite_or_case.id(), suite_or_case)] if (type(suite_or_case) in (unittest.TestSuite, ) or unpack_outer): # Plain old test suite (or any others we may add). result = [] for test in tests: # Recurse to flatten. result.extend(_flatten_tests(test)) return result else: # Find any old actual test and grab its id. suite_id = None tests = iterate_tests(suite_or_case) for test in tests: suite_id = test.id() break # If it has a sort_tests method, call that. if safe_hasattr(suite_or_case, 'sort_tests'): suite_or_case.sort_tests() return [(suite_id, suite_or_case)]
def test_tacker_command_log_defined_explicitly(self): class FakeCommand(tackerV10.TackerCommand): log = None self.assertTrue(helpers.safe_hasattr(FakeCommand, 'log')) self.assertIsNone(FakeCommand.log)
def _set_failfast(self, value): if safe_hasattr(self.decorated, 'failfast'): self.decorated.failfast = value else: self._failfast = value
def test_neutron_command_log_defined_explicitly(self): class FakeCommand(neutronV20.NeutronCommand): log = None self.assertTrue(helpers.safe_hasattr(FakeCommand, 'log')) self.assertIsNone(FakeCommand.log)
def test_apmec_command_log_defined_explicitly(self): class FakeCommand(apmecV10.ApmecCommand): log = None self.assertTrue(helpers.safe_hasattr(FakeCommand, 'log')) self.assertIsNone(FakeCommand.log)
def is_stack_hidden(): return safe_hasattr(runtest, '__unittest')