Пример #1
0
 def test_method__magic(self):
     class Class(object):
         def __foo__(self):
             pass
         def __Bar__(self):
             pass
         def __foo_bar__(self):
             pass
         def __FooBar__(self):
             pass
     self.assertTrue(__unit__.is_magic(Class.__foo__))
     self.assertTrue(__unit__.is_magic(Class.__Bar__))
     self.assertTrue(__unit__.is_magic(Class.__foo_bar__))
     self.assertTrue(__unit__.is_magic(Class.__FooBar__))
Пример #2
0
 def test_method__public(self):
     class Class(object):
         def foo(self):
             pass
         def Bar(self):
             pass
         def foo_bar(self):
             pass
         def FooBar(self):
             pass
     self.assertFalse(__unit__.is_magic(Class.foo))
     self.assertFalse(__unit__.is_magic(Class.Bar))
     self.assertFalse(__unit__.is_magic(Class.foo_bar))
     self.assertFalse(__unit__.is_magic(Class.FooBar))
Пример #3
0
 def test_method__internal(self):
     class Class(object):
         def _foo(self):
             pass
         def _Bar(self):
             pass
         def _foo_bar(self):
             pass
         def _FooBar(self):
             pass
     self.assertFalse(__unit__.is_magic(Class._foo))
     self.assertFalse(__unit__.is_magic(Class._Bar))
     self.assertFalse(__unit__.is_magic(Class._foo_bar))
     self.assertFalse(__unit__.is_magic(Class._FooBar))
Пример #4
0
    def test_method__magic(self):
        class Class(object):
            def __foo__(self):
                pass

            def __Bar__(self):
                pass

            def __foo_bar__(self):
                pass

            def __FooBar__(self):
                pass

        self.assertTrue(__unit__.is_magic(Class.__foo__))
        self.assertTrue(__unit__.is_magic(Class.__Bar__))
        self.assertTrue(__unit__.is_magic(Class.__foo_bar__))
        self.assertTrue(__unit__.is_magic(Class.__FooBar__))
Пример #5
0
    def test_method__public(self):
        class Class(object):
            def foo(self):
                pass

            def Bar(self):
                pass

            def foo_bar(self):
                pass

            def FooBar(self):
                pass

        self.assertFalse(__unit__.is_magic(Class.foo))
        self.assertFalse(__unit__.is_magic(Class.Bar))
        self.assertFalse(__unit__.is_magic(Class.foo_bar))
        self.assertFalse(__unit__.is_magic(Class.FooBar))
Пример #6
0
    def test_method__internal(self):
        class Class(object):
            def _foo(self):
                pass

            def _Bar(self):
                pass

            def _foo_bar(self):
                pass

            def _FooBar(self):
                pass

        self.assertFalse(__unit__.is_magic(Class._foo))
        self.assertFalse(__unit__.is_magic(Class._Bar))
        self.assertFalse(__unit__.is_magic(Class._foo_bar))
        self.assertFalse(__unit__.is_magic(Class._FooBar))
Пример #7
0
    def __call__(self, class_):
        for name, method in get_methods(class_):
            if is_internal(name) or is_magic(name):
                continue

            # TODO(xion): warn about terminator method names
            # that haven't been encountered in the decorated ``class_``
            if not self._is_terminator(name, method):
                fluent_method = self._make_fluent(method)
                setattr(class_, name, fluent_method)

        return class_
Пример #8
0
    def __call__(self, class_):
        for name, method in get_methods(class_):
            if is_internal(name) or is_magic(name):
                continue

            # TODO(xion): warn about terminator method names
            # that haven't been encountered in the decorated ``class_``
            if not self._is_terminator(name, method):
                fluent_method = self._make_fluent(method)
                setattr(class_, name, fluent_method)

        return class_
Пример #9
0
 def test_some_object(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(object())
Пример #10
0
 def test_none(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(None)
Пример #11
0
 def test_string__empty(self):
     self.assertFalse(__unit__.is_magic(''))
Пример #12
0
 def test_none(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(None)
Пример #13
0
 def test_string__magic_identifiers(self):
     self.assertTrue(__unit__.is_magic('__foo__'))
     self.assertTrue(__unit__.is_magic('__Bar__'))
     self.assertTrue(__unit__.is_magic('__foo_bar__'))
     self.assertTrue(__unit__.is_magic('__FooBar__'))
Пример #14
0
 def test_string__internal_identifiers(self):
     self.assertFalse(__unit__.is_magic('_foo'))
     self.assertFalse(__unit__.is_magic('_Bar'))
     self.assertFalse(__unit__.is_magic('_foo_bar'))
     self.assertFalse(__unit__.is_magic('_FooBar'))
Пример #15
0
 def test_string__public_identifiers(self):
     self.assertFalse(__unit__.is_magic('foo'))
     self.assertFalse(__unit__.is_magic('Bar'))
     self.assertFalse(__unit__.is_magic('foo_bar'))
     self.assertFalse(__unit__.is_magic('FooBar'))
Пример #16
0
 def test_string__empty(self):
     self.assertFalse(__unit__.is_magic(''))
Пример #17
0
 def test_string__public_identifiers(self):
     self.assertFalse(__unit__.is_magic('foo'))
     self.assertFalse(__unit__.is_magic('Bar'))
     self.assertFalse(__unit__.is_magic('foo_bar'))
     self.assertFalse(__unit__.is_magic('FooBar'))
Пример #18
0
 def test_string__internal_identifiers(self):
     self.assertFalse(__unit__.is_magic('_foo'))
     self.assertFalse(__unit__.is_magic('_Bar'))
     self.assertFalse(__unit__.is_magic('_foo_bar'))
     self.assertFalse(__unit__.is_magic('_FooBar'))
Пример #19
0
 def test_string__magic_identifiers(self):
     self.assertTrue(__unit__.is_magic('__foo__'))
     self.assertTrue(__unit__.is_magic('__Bar__'))
     self.assertTrue(__unit__.is_magic('__foo_bar__'))
     self.assertTrue(__unit__.is_magic('__FooBar__'))
Пример #20
0
 def test_some_object(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(object())