Skip to content

Commit

Permalink
Add test to make sure the property cache is freed as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Larralde committed Nov 23, 2018
1 parent 3159903 commit fd5166d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_cached_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ def test_threads(self):
self.assert_cached(check, num_threads)
self.assert_cached(check, num_threads)

def test_garbage_collection(self):
Check = CheckFactory(self.cached_property_factory)
check = Check()
check.add_cached = "foo"

# check the instance is in the cache
self.assertIn(check, Check.add_cached.cache)
# remove the only reference to the Check instance
del check
# make sure the cache of the deleted object was removed
self.assertEqual(Check.add_cached.cache, {})

def test_object_independent(self):
Check = CheckFactory(self.cached_property_factory)
check1 = Check()
Expand Down

0 comments on commit fd5166d

Please sign in to comment.