test #12216
(self)
| 1308 | return Target |
| 1309 | |
| 1310 | def test_two_subclasses_one_event(self): |
| 1311 | """test #12216""" |
| 1312 | |
| 1313 | Target = self._fixture() |
| 1314 | |
| 1315 | class TargetSubclassOne(Target): |
| 1316 | pass |
| 1317 | |
| 1318 | class TargetSubclassTwo(Target): |
| 1319 | pass |
| 1320 | |
| 1321 | m1 = Mock() |
| 1322 | |
| 1323 | def my_event_one(x, y): |
| 1324 | m1.my_event_one(x, y) |
| 1325 | |
| 1326 | event.listen(TargetSubclassOne, "event_one", my_event_one) |
| 1327 | event.listen(TargetSubclassTwo, "event_one", my_event_one) |
| 1328 | |
| 1329 | t1 = TargetSubclassOne() |
| 1330 | t2 = TargetSubclassTwo() |
| 1331 | |
| 1332 | t1.dispatch.event_one("x1a", "y1a") |
| 1333 | t2.dispatch.event_one("x2a", "y2a") |
| 1334 | |
| 1335 | eq_( |
| 1336 | m1.mock_calls, |
| 1337 | [call.my_event_one("x1a", "y1a"), call.my_event_one("x2a", "y2a")], |
| 1338 | ) |
| 1339 | |
| 1340 | event.remove(TargetSubclassOne, "event_one", my_event_one) |
| 1341 | |
| 1342 | t1.dispatch.event_one("x1b", "y1b") |
| 1343 | t2.dispatch.event_one("x2b", "y2b") |
| 1344 | |
| 1345 | eq_( |
| 1346 | m1.mock_calls, |
| 1347 | [ |
| 1348 | call.my_event_one("x1a", "y1a"), |
| 1349 | call.my_event_one("x2a", "y2a"), |
| 1350 | call.my_event_one("x2b", "y2b"), |
| 1351 | ], |
| 1352 | ) |
| 1353 | |
| 1354 | event.remove(TargetSubclassTwo, "event_one", my_event_one) |
| 1355 | |
| 1356 | t1.dispatch.event_one("x1c", "y1c") |
| 1357 | t2.dispatch.event_one("x2c", "y2c") |
| 1358 | |
| 1359 | eq_( |
| 1360 | m1.mock_calls, |
| 1361 | [ |
| 1362 | call.my_event_one("x1a", "y1a"), |
| 1363 | call.my_event_one("x2a", "y2a"), |
| 1364 | call.my_event_one("x2b", "y2b"), |
| 1365 | ], |
| 1366 | ) |
| 1367 |
nothing calls this directly
no test coverage detected