MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_instance

Method test_instance

test/base/test_events.py:1446–1470  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1444 eq_(m1.mock_calls, [call("x")])
1445
1446 def test_instance(self):
1447 Target = self._fixture()
1448
1449 class Foo:
1450 def __init__(self):
1451 self.mock = Mock()
1452
1453 def evt(self, arg):
1454 self.mock(arg)
1455
1456 f1 = Foo()
1457 f2 = Foo()
1458
1459 event.listen(Target, "event_one", f1.evt)
1460 event.listen(Target, "event_one", f2.evt)
1461
1462 t1 = Target()
1463 t1.dispatch.event_one("x")
1464
1465 event.remove(Target, "event_one", f1.evt)
1466
1467 t1.dispatch.event_one("y")
1468
1469 eq_(f1.mock.mock_calls, [call("x")])
1470 eq_(f2.mock.mock_calls, [call("x"), call("y")])
1471
1472 def test_once(self):
1473 Target = self._fixture()

Callers

nothing calls this directly

Calls 8

_fixtureMethod · 0.95
eq_Function · 0.90
callFunction · 0.85
FooClass · 0.70
TargetClass · 0.70
listenMethod · 0.45
event_oneMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected