Show More
@@ -27,20 +27,6 b' def test_SubClass():' | |||
|
27 | 27 | nt.assert_equal(res.count('x'), 1) |
|
28 | 28 | |
|
29 | 29 | |
|
30 | def test_SubClass_with_trait_names_method(): | |
|
31 | ||
|
32 | class SubClass(Base): | |
|
33 | y = 2 | |
|
34 | def trait_names(self): | |
|
35 | return ['t', 'umbrella'] | |
|
36 | ||
|
37 | res = dir2(SubClass()) | |
|
38 | assert('trait_names' in res) | |
|
39 | assert('umbrella' in res) | |
|
40 | nt.assert_equal(res[-6:], ['t', 'trait_names','umbrella', 'x','y','z']) | |
|
41 | nt.assert_equal(res.count('t'), 1) | |
|
42 | ||
|
43 | ||
|
44 | 30 | def test_SubClass_with_trait_names_attr(): |
|
45 | 31 | # usecase: trait_names is used in a class describing psychological classification |
|
46 | 32 | |
@@ -56,14 +42,6 b' def test_misbehaving_object_without_trait_names():' | |||
|
56 | 42 | # dir2 shouldn't raise even when objects are dumb and raise |
|
57 | 43 | # something other than AttribteErrors on bad getattr. |
|
58 | 44 | |
|
59 | class BadTraitNames(object): | |
|
60 | @property | |
|
61 | def trait_names(self): | |
|
62 | raise KeyboardInterrupt("This should be caught") | |
|
63 | ||
|
64 | def some_method(self): | |
|
65 | pass | |
|
66 | ||
|
67 | 45 | class MisbehavingGetattr(object): |
|
68 | 46 | def __getattr__(self): |
|
69 | 47 | raise KeyError("I should be caught") |
@@ -75,6 +53,6 b' def test_misbehaving_object_without_trait_names():' | |||
|
75 | 53 | def __dir__(self): |
|
76 | 54 | return ['some_method'] |
|
77 | 55 | |
|
78 |
for bad_klass in ( |
|
|
56 | for bad_klass in (MisbehavingGetattr, SillierWithDir): | |
|
79 | 57 | res = dir2(bad_klass()) |
|
80 | 58 | assert('some_method' in res) |
General Comments 0
You need to be logged in to leave comments.
Login now