From e9e7ff16ad5e8e8ec78ea07ffd420b2cb809bff2 Mon Sep 17 00:00:00 2001 From: Johann Bauer Date: Sun, 27 Nov 2016 21:44:42 +0100 Subject: [PATCH] Add tests for `close`. --- tests/test_storage.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_storage.py b/tests/test_storage.py index 2c3d429..504f3f5 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -22,8 +22,8 @@ def db(tmpdir, request): cwd = os.getcwd() os.chdir(str(tmpdir)) db = open_db("db", request.param, False) - os.chdir(cwd) yield db + os.chdir(cwd) # Make sure all the locks and handles are closed del db gc.collect() @@ -67,3 +67,10 @@ def test_iterator_reverse(db): (b"abc" + str.encode(str(i)), str.encode(str(i))) for i in reversed(range(5)) ] + + +def test_close(db): + db.put(b"a", b"b") + db.close() + db = open_db("db", db.__class__.__name__, False) + assert db.get(b"a") == b"b" \ No newline at end of file