MCPcopy Create free account
hub / github.com/LabPy/lantz / test_derived_class_post

Method test_derived_class_post

lantz/testsuite/test_driver.py:269–322  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

267 self.assertEqual(n.action1(), 'action1')
268
269 def test_derived_class_post(self):
270
271 class X(object):
272
273 @Feat()
274 def feat1(self):
275 return 'feat1'
276
277 @Action()
278 def action1(self):
279 return 'action1'
280
281 class Y(X, Driver):
282
283 @Feat()
284 def feat2(self):
285 return 'feat2'
286
287 @Action()
288 def action2(self):
289 return 'action2'
290
291 class Z(X, Driver):
292
293 @Feat()
294 def feat1(self):
295 return super().feat1 + ' in Z'
296
297 @Action()
298 def action1(self):
299 return super().action1() + ' in Z'
300
301 class N(X, Driver):
302 pass
303
304 y = Y()
305 z = Z()
306 n = N()
307 self.assertEqual(set(y._lantz_features.keys()), {'feat1', 'feat2'})
308 self.assertEqual(set(z._lantz_features.keys()), {'feat1', })
309 self.assertEqual(set(n._lantz_features.keys()), {'feat1', })
310
311 self.assertEqual(set(y._lantz_actions.keys()), {'action1', 'action2', 'initialize', 'finalize'})
312 self.assertEqual(set(z._lantz_actions.keys()), {'action1', 'initialize', 'finalize'})
313 self.assertEqual(set(n._lantz_actions.keys()), {'action1', 'initialize', 'finalize'})
314
315 self.assertEqual(y.refresh(), {'feat1': 'feat1', 'feat2': 'feat2'})
316 self.assertEqual(z.refresh(), {'feat1': 'feat1 in Z'})
317 self.assertEqual(n.refresh(), {'feat1': 'feat1'})
318
319 self.assertEqual(y.action1(), 'action1')
320 self.assertEqual(y.action2(), 'action2')
321 self.assertEqual(z.action1(), 'action1 in Z')
322 self.assertEqual(n.action1(), 'action1')
323
324 def test_Self_exceptions(self):
325

Callers

nothing calls this directly

Calls 9

action2Method · 0.95
action1Method · 0.95
YClass · 0.85
ZClass · 0.85
NClass · 0.85
refreshMethod · 0.80
setFunction · 0.50
keysMethod · 0.45
action1Method · 0.45

Tested by

no test coverage detected