Issue #19607: Use specific asserts in weakref tests.