Ejemplo n.º 1
0
def is_magic(member):
    """Checks whether given class/instance member, or its name, is "magic".

    Magic fields and methods have names that begin and end
    with double underscores, such ``__hash__`` or ``__eq__``.
    """
    return lang.is_magic(_get_member_name(member))
Ejemplo n.º 2
0
def is_magic(member):
    """Checks whether given class/instance member, or its name, is "magic".

    Magic fields and methods have names that begin and end
    with double underscores, such ``__hash__`` or ``__eq__``.
    """
    return lang.is_magic(_get_member_name(member))
Ejemplo n.º 3
0
 def test_string__underscore_suffix(self):
     self.assertFalse(__unit__.is_magic('foo_'))
Ejemplo n.º 4
0
 def test_string__just_letters(self):
     self.assertFalse(__unit__.is_magic('FooBar'))
     self.assertFalse(__unit__.is_magic('fooBar'))
Ejemplo n.º 5
0
 def test_string__double_underscore_prefix(self):
     self.assertFalse(__unit__.is_magic('__foo'))
     self.assertFalse(__unit__.is_magic('__Foo'))
Ejemplo n.º 6
0
 def test_string__empty(self):
     self.assertFalse(__unit__.is_magic(''))
Ejemplo n.º 7
0
 def test_string__number(self):
     self.assertFalse(__unit__.is_magic('42'))
Ejemplo n.º 8
0
 def test_string__number(self):
     self.assertFalse(__unit__.is_magic('42'))
Ejemplo n.º 9
0
 def test_some_object(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(object())
Ejemplo n.º 10
0
 def test_string__magic(self):
     self.assertTrue(__unit__.is_magic('__foo__'))
     self.assertTrue(__unit__.is_magic('__FooBar__'))
Ejemplo n.º 11
0
 def test_string__magic(self):
     self.assertTrue(__unit__.is_magic('__foo__'))
     self.assertTrue(__unit__.is_magic('__FooBar__'))
Ejemplo n.º 12
0
 def test_string__single_underscore(self):
     self.assertFalse(__unit__.is_magic('_'))
Ejemplo n.º 13
0
 def test_string__four_underscores(self):
     self.assertFalse(__unit__.is_magic('____'))
Ejemplo n.º 14
0
 def test_string__underscore_suffix(self):
     self.assertFalse(__unit__.is_magic('foo_'))
Ejemplo n.º 15
0
 def test_string__double_underscore_prefix(self):
     self.assertFalse(__unit__.is_magic('__foo'))
     self.assertFalse(__unit__.is_magic('__Foo'))
Ejemplo n.º 16
0
 def test_string__just_letters(self):
     self.assertFalse(__unit__.is_magic('FooBar'))
     self.assertFalse(__unit__.is_magic('fooBar'))
Ejemplo n.º 17
0
 def test_string__single_underscore(self):
     self.assertFalse(__unit__.is_magic('_'))
Ejemplo n.º 18
0
 def test_some_object(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(object())
Ejemplo n.º 19
0
 def test_string__four_underscores(self):
     self.assertFalse(__unit__.is_magic('____'))
Ejemplo n.º 20
0
 def test_string__empty(self):
     self.assertFalse(__unit__.is_magic(''))
Ejemplo n.º 21
0
 def test_none(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(None)
Ejemplo n.º 22
0
 def test_none(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(None)