File tree Expand file tree Collapse file tree 2 files changed +37
-6
lines changed
Expand file tree Collapse file tree 2 files changed +37
-6
lines changed Original file line number Diff line number Diff line change 3535try :
3636 collections .Callable
3737 has_collections_callable = True
38- try :
39- import types
40- types .InstanceType
41- has_instance_type = True
42- except AttributeError :
43- has_instance_type = False
4438except AttributeError :
4539 has_collections_callable = False
40+ try :
41+ import types
42+ types .InstanceType
43+ has_instance_type = True
44+ except AttributeError :
45+ has_instance_type = False
4646
4747py3 = sys .version_info [0 ] == 3
4848
Original file line number Diff line number Diff line change 1+ import unittest
2+
3+ from bpython import inspection
4+
5+ class TestInspection (unittest .TestCase ):
6+ def test_is_callable (self ):
7+ class OldCallable :
8+ def __call__ (self ):
9+ pass
10+
11+ class Callable (object ):
12+ def __call__ (self ):
13+ pass
14+
15+ class OldNoncallable :
16+ pass
17+
18+ class Noncallable (object ):
19+ pass
20+
21+ def spam ():
22+ pass
23+
24+ self .assertTrue (inspection .is_callable (spam ))
25+ self .assertTrue (inspection .is_callable (Callable ))
26+ self .assertTrue (inspection .is_callable (Callable ()))
27+ self .assertTrue (inspection .is_callable (OldCallable ))
28+ self .assertTrue (inspection .is_callable (OldCallable ()))
29+ self .assertFalse (inspection .is_callable (Noncallable ()))
30+ self .assertFalse (inspection .is_callable (OldNoncallable ()))
31+ self .assertFalse (inspection .is_callable (None ))
You can’t perform that action at this time.
0 commit comments