Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 8b4904e + 0befb0b commit 85ec8d9Copy full SHA for 85ec8d9
numpy/lib/tests/test_io.py
@@ -1905,12 +1905,17 @@ def test_load_refcount():
1905
np.savez(f, [1, 2, 3])
1906
f.seek(0)
1907
1908
- gc.collect()
1909
- n_before = len(gc.get_objects())
1910
- np.load(f)
1911
- n_after = len(gc.get_objects())
1912
-
1913
- 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
1914
+ # were found -- we are checking that no cycles were created by np.load
1915
+ n_objects_in_cycles = gc.collect()
1916
+ finally:
1917
+ gc.enable()
1918
+ assert_equal(n_objects_in_cycles, 0)
1919
1920
if __name__ == "__main__":
1921
run_module_suite()
0 commit comments