Exemplo n.º 1
0
    def test_walk_class_hierarchy(self):
        class A(object):
            pass

        class B(A):
            pass

        class C(A):
            pass

        class D(B):
            pass

        class E(A):
            pass

        class_pairs = zip((D, B, E),
                          utils.walk_class_hierarchy(A, encountered=[C]))
        for actual, expected in class_pairs:
            self.assertEqual(expected, actual)

        class_pairs = zip((D, B, C, E), utils.walk_class_hierarchy(A))
        for actual, expected in class_pairs:
            self.assertEqual(expected, actual)
Exemplo n.º 2
0
    def test_walk_class_hierarchy(self):
        class A(object):
            pass

        class B(A):
            pass

        class C(A):
            pass

        class D(B):
            pass

        class E(A):
            pass

        class_pairs = zip((D, B, E),
                          utils.walk_class_hierarchy(A, encountered=[C]))
        for actual, expected in class_pairs:
            self.assertEqual(expected, actual)

        class_pairs = zip((D, B, C, E), utils.walk_class_hierarchy(A))
        for actual, expected in class_pairs:
            self.assertEqual(expected, actual)
 def status_to_type(status):
     if not FaultWrapper._status_to_type:
         for clazz in utils.walk_class_hierarchy(webob.exc.HTTPError):
             FaultWrapper._status_to_type[clazz.code] = clazz
     return FaultWrapper._status_to_type.get(
         status, webob.exc.HTTPInternalServerError)()
Exemplo n.º 4
0
 def status_to_type(status):
     if not FaultWrapper._status_to_type:
         for clazz in utils.walk_class_hierarchy(webob.exc.HTTPError):
             FaultWrapper._status_to_type[clazz.code] = clazz
     return FaultWrapper._status_to_type.get(
         status, webob.exc.HTTPInternalServerError)()