@@ -146,37 +146,39 @@ class Property(object):
146146 def prop (self ):
147147 raise AssertionError ('Property __get__ executed' )
148148
149+
149150class Slots (object ):
150151 __slots__ = ['s1' , 's2' ]
151152
153+
152154class TestSafeGetAttribute (unittest .TestCase ):
153155
154156 def test_lookup_on_object (self ):
155157 a = A ()
156158 a .x = 1
157- self .assertEquals (inspection .safe_get_attribute (a , 'x' ), 1 )
158- self .assertEquals (inspection .safe_get_attribute (a , 'a' ), 'a' )
159+ self .assertEquals (inspection .safe_get_attribute_new_style (a , 'x' ), 1 )
160+ self .assertEquals (inspection .safe_get_attribute_new_style (a , 'a' ), 'a' )
159161 b = B ()
160162 b .y = 2
161- self .assertEquals (inspection .safe_get_attribute (b , 'y' ), 2 )
162- self .assertEquals (inspection .safe_get_attribute (b , 'a' ), 'a' )
163- self .assertEquals (inspection .safe_get_attribute (b , 'b' ), 'b' )
163+ self .assertEquals (inspection .safe_get_attribute_new_style (b , 'y' ), 2 )
164+ self .assertEquals (inspection .safe_get_attribute_new_style (b , 'a' ), 'a' )
165+ self .assertEquals (inspection .safe_get_attribute_new_style (b , 'b' ), 'b' )
164166
165167 def test_avoid_running_properties (self ):
166168 p = Property ()
167- self .assertEquals (inspection .safe_get_attribute (p , 'prop' ),
169+ self .assertEquals (inspection .safe_get_attribute_new_style (p , 'prop' ),
168170 Property .prop )
169171
170172 def test_raises_on_old_style_class (self ):
171173 class Old : pass
172174 with self .assertRaises (ValueError ):
173- inspection .safe_get_attribute (Old , 'asdf' )
175+ inspection .safe_get_attribute_new_style (Old , 'asdf' )
174176
175177 def test_lookup_with_slots (self ):
176178 s = Slots ()
177179 s .s1 = 's1'
178- self .assertEquals (inspection .safe_get_attribute (s , 's1' ), 's1' )
179- self .assertEquals (inspection .safe_get_attribute (s , 's2' ),
180+ self .assertEquals (inspection .safe_get_attribute_new_style (s , 's1' ), 's1' )
181+ self .assertEquals (inspection .safe_get_attribute_new_style (s , 's2' ),
180182 inspection .AttributeIsEmptySlot )
181183
182184
0 commit comments