Exemple #1
0
 def test_staticmethod(self):
     class Foo(object):
         @staticmethod
         def foo():
             pass
     with self.assertRaises(TypeError):
         __unit__.ensure_method(Foo.foo)
Exemple #2
0
    def test_classmethod__of_instance(self):
        class Foo(object):
            @classmethod
            def foo(cls):
                pass

        __unit__.ensure_method(Foo().foo)
Exemple #3
0
    def test_staticmethod(self):
        class Foo(object):
            @staticmethod
            def foo():
                pass

        with self.assertRaises(TypeError):
            __unit__.ensure_method(Foo.foo)
Exemple #4
0
    def test_regular_method_attached_to_class__of_instance(self):
        class Foo(object):
            pass
        def foo(self):
            pass
        Foo.foo = foo

        __unit__.ensure_method(Foo().foo)
Exemple #5
0
    def __call__(self, method):
        try:
            ensure_method(method)
        except TypeError:
            if not _OverrideDecorator.maybe_signal_classmethod(method):
                raise

        return _OverriddenMethod(method, self)  # remember the override's base
Exemple #6
0
def _get_member_name(member):
    if is_string(member):
        return member

    # Python has no "field declaration" objects, so the only valid
    # class or instance member is actually a method
    from taipan.objective.methods import ensure_method
    ensure_method(member)
    return member.__name__
Exemple #7
0
def _get_member_name(member):
    if is_string(member):
        return member

    # Python has no "field declaration" objects, so the only valid
    # class or instance member is actually a method
    from taipan.objective.methods import ensure_method
    ensure_method(member)
    return member.__name__
Exemple #8
0
    def test_function_attached_to_object(self):
        class Foo(object):
            pass
        def foo(self):
            pass

        obj = Foo()
        obj.foo = foo
        __unit__.ensure_method(obj.foo)
Exemple #9
0
    def test_classmethod_attached_to_class(self):
        class Foo(object):
            pass
        @classmethod
        def foo(cls):
            pass
        Foo.foo = foo

        __unit__.ensure_method(Foo.foo)
Exemple #10
0
    def test_function_attached_to_object(self):
        class Foo(object):
            pass

        def foo(self):
            pass

        obj = Foo()
        obj.foo = foo
        __unit__.ensure_method(obj.foo)
Exemple #11
0
    def test_regular_method_attached_to_class__of_instance(self):
        class Foo(object):
            pass

        def foo(self):
            pass

        Foo.foo = foo

        __unit__.ensure_method(Foo().foo)
Exemple #12
0
    def test_classmethod_attached_to_class(self):
        class Foo(object):
            pass

        @classmethod
        def foo(cls):
            pass

        Foo.foo = foo

        __unit__.ensure_method(Foo.foo)
Exemple #13
0
 def test_none(self):
     with self.assertRaises(TypeError):
         __unit__.ensure_method(None)
Exemple #14
0
    def test_regular_method__of_instance(self):
        class Foo(object):
            def foo(self):
                pass

        __unit__.ensure_method(Foo().foo)
Exemple #15
0
 def test_lambda(self):
     foo = lambda: None
     with self.assertRaises(TypeError):
         __unit__.ensure_method(foo)
Exemple #16
0
 def test_regular_function(self):
     def foo():
         pass
     with self.assertRaises(TypeError):
         __unit__.ensure_method(foo)
Exemple #17
0
    def test_regular_function(self):
        def foo():
            pass

        with self.assertRaises(TypeError):
            __unit__.ensure_method(foo)
Exemple #18
0
 def test_lambda(self):
     foo = lambda: None
     with self.assertRaises(TypeError):
         __unit__.ensure_method(foo)
Exemple #19
0
 def test_some_object(self):
     with self.assertRaises(TypeError):
         __unit__.ensure_method(object())
Exemple #20
0
 def test_classmethod__of_instance(self):
     class Foo(object):
         @classmethod
         def foo(cls):
             pass
     __unit__.ensure_method(Foo().foo)
Exemple #21
0
 def test_regular_method__of_instance(self):
     class Foo(object):
         def foo(self):
             pass
     __unit__.ensure_method(Foo().foo)
Exemple #22
0
 def test_some_object(self):
     with self.assertRaises(TypeError):
         __unit__.ensure_method(object())
Exemple #23
0
 def test_none(self):
     with self.assertRaises(TypeError):
         __unit__.ensure_method(None)