diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2015-10-29 12:22:45 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2015-10-29 12:22:45 -0600 |
commit | 85ec8d99730208f5880a28a531b723ac8a1bc66e (patch) | |
tree | 75c12b9e56e76ffefac186c9ca4ddaea5b54774b | |
parent | 8b4904efb4c4321e87a12cdc781247fd2a8b86a6 (diff) | |
parent | 0befb0b3444804b8a212ef069c4c3f141d19750b (diff) | |
download | numpy-85ec8d99730208f5880a28a531b723ac8a1bc66e.tar.gz |
Merge pull request #6576 from njsmith/test_load_refcount-fix
TST: attempt to make test_load_refcount deterministic
-rw-r--r-- | numpy/lib/tests/test_io.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index f4ce67805..af904e96a 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -1905,12 +1905,17 @@ def test_load_refcount(): np.savez(f, [1, 2, 3]) f.seek(0) - gc.collect() - n_before = len(gc.get_objects()) - np.load(f) - n_after = len(gc.get_objects()) - - assert_equal(n_before, n_after) + assert_(gc.isenabled()) + gc.disable() + try: + gc.collect() + np.load(f) + # gc.collect returns the number of unreachable objects in cycles that + # were found -- we are checking that no cycles were created by np.load + n_objects_in_cycles = gc.collect() + finally: + gc.enable() + assert_equal(n_objects_in_cycles, 0) if __name__ == "__main__": run_module_suite() |