Skip to content

Commit

Permalink
Test self-assigned keys get del when out of scope (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
brainix authored Dec 3, 2020
1 parent ffb97ee commit 6619db8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# --------------------------------------------------------------------------- #


import gc
import unittest.mock

from pottery import RandomKeyError
Expand Down Expand Up @@ -47,6 +48,16 @@ def tearDown(self):


class CommonTests(_BaseTestCase):
def test_out_of_scope(self):
def scope():
raj = RedisDict(hobby='music', vegetarian=True)
assert self.redis.exists(raj.key)
return raj.key

key = scope()
gc.collect()
assert not self.redis.exists(key)

def test_del(self):
with unittest.mock.patch.object(self.redis, 'delete') as delete:
del self.raj
Expand Down

0 comments on commit 6619db8

Please sign in to comment.