コード例 #1
0
ファイル: test_coordination.py プロジェクト: liunian0o0/tooz
 def assertRaisesAny(self, exc_classes, callable_obj, *args, **kwargs):
     checkers = [
         matchers.MatchesException(exc_class) for exc_class in exc_classes
     ]
     matcher = matchers.Raises(matchers.MatchesAny(*checkers))
     callable_obj = testcase.Nullary(callable_obj, *args, **kwargs)
     self.assertThat(callable_obj, matcher)
コード例 #2
0
ファイル: base.py プロジェクト: att-comdev/test-submit
 def _validate_object(self, obj):
     for attr in BASE_EXPECTED_FIELDS:
         if attr.endswith('_at'):
             self.assertThat(
                 obj[attr],
                 matchers.MatchesAny(matchers.Is(None),
                                     matchers.IsInstance(str)))
         else:
             self.assertIsInstance(obj[attr], bool)
コード例 #3
0
 def test_must_specify_tags_with_tags_options(self):
     fn = lambda: safe_parse_arguments(['--fail', 'foo', '--tag'])
     self.assertThat(
         fn,
         matchers.MatchesAny(
             matchers.raises(
                 RuntimeError('--tag option requires 1 argument')),
             matchers.raises(
                 RuntimeError('--tag option requires an argument'))))
コード例 #4
0
ファイル: test_hash_ring.py プロジェクト: zweiustc/ironic
 def test_ignore_hosts(self):
     hosts = ['foo', 'bar', 'baz']
     ring = hash_ring.HashRing(hosts, replicas=1)
     equals_bar_or_baz = matchers.MatchesAny(matchers.Equals(['bar']),
                                             matchers.Equals(['baz']))
     self.assertThat(ring.get_hosts('fake', ignore_hosts=['foo']),
                     equals_bar_or_baz)
     self.assertThat(ring.get_hosts('fake', ignore_hosts=['foo', 'bar']),
                     equals_bar_or_baz)
     self.assertEqual([], ring.get_hosts('fake', ignore_hosts=hosts))
コード例 #5
0
ファイル: test_service.py プロジェクト: shad7/tvrenamer
 def test_setup_logging_no_logging(self):
     self.CONF.set_override('logfile', None)
     self.CONF.set_override('console_output_enabled', False)
     del logging.getLogger().handlers[:]
     service._setup_logging()
     for hndler in logging.getLogger().handlers:
         self.assertThat(
             hndler,
             matchers.MatchesAny(
                 matchers.IsInstance(logging.NullHandler)))
コード例 #6
0
ファイル: test_service.py プロジェクト: shad7/tvrenamer
 def test_setup_logging_console(self):
     self.CONF.set_override('logfile', None)
     del logging.getLogger().handlers[:]
     service._setup_logging()
     for hndler in logging.getLogger().handlers:
         self.assertThat(
             hndler,
             matchers.MatchesAny(
                 matchers.IsInstance(logging.StreamHandler),
                 matchers.IsInstance(logging.NullHandler)))
コード例 #7
0
 def test_ignore_nodes(self):
     nodes = ['foo', 'bar', 'baz']
     ring = hashring.HashRing(nodes)
     equals_bar_or_baz = matchers.MatchesAny(matchers.Equals({'bar'}),
                                             matchers.Equals({'baz'}))
     self.assertThat(ring.get_nodes(b'fake', ignore_nodes=['foo']),
                     equals_bar_or_baz)
     self.assertThat(ring.get_nodes(b'fake', ignore_nodes=['foo', 'bar']),
                     equals_bar_or_baz)
     self.assertEqual(set(), ring.get_nodes(b'fake', ignore_nodes=nodes))
コード例 #8
0
ファイル: test_service.py プロジェクト: shad7/tvrenamer
    def test_setup_logging(self):
        del logging.getLogger().handlers[:]
        service._setup_logging()
        self.assertEqual(logging.getLogger().getEffectiveLevel(),
                         logging.INFO)
        self.assertEqual(
            logging.getLogger('tvdbapi_client').getEffectiveLevel(),
            logging.WARNING)

        for hndler in logging.getLogger().handlers:
            self.assertThat(
                hndler,
                matchers.MatchesAny(
                    matchers.IsInstance(logging.handlers.RotatingFileHandler),
                    matchers.IsInstance(logging.StreamHandler),
                    matchers.IsInstance(logging.NullHandler)))