(cl, method, *args)
| 398 | |
| 399 | @pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC") |
| 400 | def assert_keeps_alive(cl, method, *args): |
| 401 | cstats = ConstructorStats.get(cl) |
| 402 | start_with = cstats.alive() |
| 403 | a = cl() |
| 404 | assert cstats.alive() == start_with + 1 |
| 405 | z = method(a, *args) |
| 406 | assert cstats.alive() == start_with + 1 |
| 407 | del a |
| 408 | # Here's the keep alive in action: |
| 409 | assert cstats.alive() == start_with + 1 |
| 410 | del z |
| 411 | # Keep alive should have expired: |
| 412 | assert cstats.alive() == start_with |
| 413 | |
| 414 | |
| 415 | @pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC") |
no test coverage detected