예제 #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))
예제 #2
0
파일: __init__.py 프로젝트: Xion/taipan
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))
예제 #3
0
파일: test_lang.py 프로젝트: Xion/taipan
 def test_string__underscore_suffix(self):
     self.assertFalse(__unit__.is_magic('foo_'))
예제 #4
0
파일: test_lang.py 프로젝트: Xion/taipan
 def test_string__just_letters(self):
     self.assertFalse(__unit__.is_magic('FooBar'))
     self.assertFalse(__unit__.is_magic('fooBar'))
예제 #5
0
파일: test_lang.py 프로젝트: Xion/taipan
 def test_string__double_underscore_prefix(self):
     self.assertFalse(__unit__.is_magic('__foo'))
     self.assertFalse(__unit__.is_magic('__Foo'))
예제 #6
0
파일: test_lang.py 프로젝트: Xion/taipan
 def test_string__empty(self):
     self.assertFalse(__unit__.is_magic(''))
예제 #7
0
파일: test_lang.py 프로젝트: Xion/taipan
 def test_string__number(self):
     self.assertFalse(__unit__.is_magic('42'))
예제 #8
0
 def test_string__number(self):
     self.assertFalse(__unit__.is_magic('42'))
예제 #9
0
파일: test_lang.py 프로젝트: Xion/taipan
 def test_some_object(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(object())
예제 #10
0
 def test_string__magic(self):
     self.assertTrue(__unit__.is_magic('__foo__'))
     self.assertTrue(__unit__.is_magic('__FooBar__'))
예제 #11
0
파일: test_lang.py 프로젝트: Xion/taipan
 def test_string__magic(self):
     self.assertTrue(__unit__.is_magic('__foo__'))
     self.assertTrue(__unit__.is_magic('__FooBar__'))
예제 #12
0
 def test_string__single_underscore(self):
     self.assertFalse(__unit__.is_magic('_'))
예제 #13
0
 def test_string__four_underscores(self):
     self.assertFalse(__unit__.is_magic('____'))
예제 #14
0
 def test_string__underscore_suffix(self):
     self.assertFalse(__unit__.is_magic('foo_'))
예제 #15
0
 def test_string__double_underscore_prefix(self):
     self.assertFalse(__unit__.is_magic('__foo'))
     self.assertFalse(__unit__.is_magic('__Foo'))
예제 #16
0
 def test_string__just_letters(self):
     self.assertFalse(__unit__.is_magic('FooBar'))
     self.assertFalse(__unit__.is_magic('fooBar'))
예제 #17
0
파일: test_lang.py 프로젝트: Xion/taipan
 def test_string__single_underscore(self):
     self.assertFalse(__unit__.is_magic('_'))
예제 #18
0
 def test_some_object(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(object())
예제 #19
0
파일: test_lang.py 프로젝트: Xion/taipan
 def test_string__four_underscores(self):
     self.assertFalse(__unit__.is_magic('____'))
예제 #20
0
 def test_string__empty(self):
     self.assertFalse(__unit__.is_magic(''))
예제 #21
0
파일: test_lang.py 프로젝트: Xion/taipan
 def test_none(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(None)
예제 #22
0
 def test_none(self):
     with self.assertRaises(TypeError):
         __unit__.is_magic(None)