Example #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__))
Example #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))
Example #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))
Example #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__))
Example #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))
Example #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))
Example #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_
Example #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_
Example #9
0
 def test_some_object(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(object())
Example #10
0
 def test_none(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(None)
Example #11
0
 def test_string__empty(self):
     self.assertFalse(__unit__.is_magic(''))
Example #12
0
 def test_none(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(None)
Example #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__'))
Example #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'))
Example #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'))
Example #16
0
 def test_string__empty(self):
     self.assertFalse(__unit__.is_magic(''))
Example #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'))
Example #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'))
Example #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__'))
Example #20
0
 def test_some_object(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(object())