def simplify_such_that(self, t, f): tracker = Tracker() while True: for s in self.simplify(t): if tracker.track(s) > 1: continue if f(s): t = s break else: return t
def test_track_lists(): t = Tracker() assert t.track([1]) == 1 assert t.track([1]) == 2
def test_track_ints(): t = Tracker() assert t.track(1) == 1 assert t.track(1) == 2
def test_nested_unhashables(): t = Tracker() x = {"foo": [1, 2, {3, 4, 5, 6}], "bar": 10} assert t.track(x) == 1 assert t.track(x) == 2
def assert_no_duplicates_in_simplify(s, x): s = strategy(s) t = Tracker() t.track(x) for y in s.simplify(x): assert t.track(y) == 1
def test_nested_unhashables(): t = Tracker() x = {"foo" : [1,2,{3,4,5,6}], "bar" : 10} assert t.track(x) == 1 assert t.track(x) == 2