@@ -147,42 +147,46 @@ def test_values(self):
147
147
148
148
class TestPandasDelegate (tm .TestCase ):
149
149
150
- def setUp (self ):
151
- pass
150
+ class Delegator (object ):
151
+ _properties = ['foo' ]
152
+ _methods = ['bar' ]
152
153
153
- def test_invalida_delgation (self ):
154
- # these show that in order for the delegation to work
155
- # the _delegate_* methods need to be overriden to not raise a TypeError
154
+ def _set_foo (self , value ):
155
+ self .foo = value
156
156
157
- class Delegator (object ):
158
- _properties = ['foo' ]
159
- _methods = ['bar' ]
157
+ def _get_foo (self ):
158
+ return self .foo
160
159
161
- def _set_foo (self , value ):
162
- self .foo = value
160
+ foo = property (_get_foo , _set_foo , doc = "foo property" )
163
161
164
- def _get_foo (self ):
165
- return self .foo
162
+ def bar (self , * args , ** kwargs ):
163
+ """ a test bar method """
164
+ pass
166
165
167
- foo = property ( _get_foo , _set_foo , doc = "foo property" )
166
+ class Delegate ( PandasDelegate ):
168
167
169
- def bar (self , * args , ** kwargs ):
170
- """ a test bar method """
171
- pass
168
+ def __init__ (self , obj ):
169
+ self .obj = obj
172
170
173
- class Delegate (PandasDelegate ):
171
+ def setUp (self ):
172
+ pass
174
173
175
- def __init__ (self , obj ):
176
- self .obj = obj
174
+ def test_invalida_delgation (self ):
175
+ # these show that in order for the delegation to work
176
+ # the _delegate_* methods need to be overriden to not raise a TypeError
177
177
178
- Delegate ._add_delegate_accessors (delegate = Delegator ,
179
- accessors = Delegator ._properties ,
180
- typ = 'property' )
181
- Delegate ._add_delegate_accessors (delegate = Delegator ,
182
- accessors = Delegator ._methods ,
183
- typ = 'method' )
178
+ self .Delegate ._add_delegate_accessors (
179
+ delegate = self .Delegator ,
180
+ accessors = self .Delegator ._properties ,
181
+ typ = 'property'
182
+ )
183
+ self .Delegate ._add_delegate_accessors (
184
+ delegate = self .Delegator ,
185
+ accessors = self .Delegator ._methods ,
186
+ typ = 'method'
187
+ )
184
188
185
- delegate = Delegate (Delegator ())
189
+ delegate = self . Delegate (self . Delegator ())
186
190
187
191
def f ():
188
192
delegate .foo
@@ -199,6 +203,12 @@ def f():
199
203
200
204
self .assertRaises (TypeError , f )
201
205
206
+ def test_memory_usage (self ):
207
+ # Delegate does not implement memory_usage.
208
+ # Check that we fall back to in-built `__sizeof__`
209
+ delegate = self .Delegate (self .Delegator ())
210
+ sys .getsizeof (delegate )
211
+
202
212
203
213
class Ops (tm .TestCase ):
204
214
0 commit comments