コード例 #1
0
ファイル: testsuite.py プロジェクト: AIdrifter/samba
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)]
コード例 #2
0
    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")
コード例 #3
0
    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)
コード例 #4
0
ファイル: testsuite.py プロジェクト: LukeM12/samba
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)]
コード例 #5
0
    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)
コード例 #6
0
ファイル: real.py プロジェクト: AIdrifter/samba
 def _set_failfast(self, value):
     if safe_hasattr(self.decorated, 'failfast'):
         self.decorated.failfast = value
     else:
         self._failfast = value
コード例 #7
0
    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)
コード例 #8
0
    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)
コード例 #9
0
ファイル: helpers.py プロジェクト: cpatulea/samba
def is_stack_hidden():
    return safe_hasattr(runtest, '__unittest')
コード例 #10
0
ファイル: real.py プロジェクト: LukeM12/samba
 def _set_failfast(self, value):
     if safe_hasattr(self.decorated, 'failfast'):
         self.decorated.failfast = value
     else:
         self._failfast = value