(capture)
| 220 | |
| 221 | @pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC") |
| 222 | def test_keep_alive_constructor(capture): |
| 223 | n_inst = ConstructorStats.detail_reg_inst() |
| 224 | |
| 225 | with capture: |
| 226 | p = m.Parent(m.Child()) |
| 227 | assert ConstructorStats.detail_reg_inst() == n_inst + 2 |
| 228 | assert ( |
| 229 | capture |
| 230 | == """ |
| 231 | Allocating child. |
| 232 | Allocating parent. |
| 233 | """ |
| 234 | ) |
| 235 | with capture: |
| 236 | del p |
| 237 | assert ConstructorStats.detail_reg_inst() == n_inst |
| 238 | assert ( |
| 239 | capture |
| 240 | == """ |
| 241 | Releasing parent. |
| 242 | Releasing child. |
| 243 | """ |
| 244 | ) |
| 245 | |
| 246 | |
| 247 | def test_call_guard(): |