Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
A different approach to make the test deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-king-jena committed Sep 20, 2015
1 parent 0d97c7d commit 65ece65
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/sage/categories/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,19 @@ def __contains__(self, x):
The following tests against a memory leak fixed in :trac:`13370`. In order
to prevent non-deterministic deallocation of fields that have been created
in other doctests, :trac:`19244` disables garbage collection until we really
want it to happen. ::
in other doctests, we introduced a strong reference to all previously created
uncollected objects in :trac:`19244`. ::
sage: import gc
sage: _ = gc.collect()
sage: gc.disable()
sage: n = len([X for X in gc.get_objects() if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)])
sage: permstore = [X for X in gc.get_objects() if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]
sage: n = len(permstore)
sage: for i in prime_range(100):
....: R = ZZ.quotient(i)
....: t = R in Fields()
sage: len([X for X in gc.get_objects() if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]) > n
True
sage: del R
sage: gc.enable()
sage: _ = gc.collect()
sage: len([X for X in gc.get_objects() if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]) - n
0
Expand Down

0 comments on commit 65ece65

Please sign in to comment.