mirror of https://github.com/nucypher/nucypher.git
Make the default db for all tests, remove after each test
parent
a6be3fb1d9
commit
dcfec2d7ab
|
@ -1,6 +1,16 @@
|
|||
import nkms.db
|
||||
import shutil
|
||||
import os
|
||||
import appdirs
|
||||
|
||||
|
||||
def pytest_runtest_setup(item):
|
||||
# Monkey-patching for tests so that we don't overwrite the default db
|
||||
nkms.db.DB_NAME = 'debug-rekeys-db'
|
||||
|
||||
|
||||
def pytest_runtest_teardown(item, nextitem):
|
||||
path = os.path.join(
|
||||
appdirs.user_data_dir(nkms.db.CONFIG_APPNAME), nkms.db.DB_NAME)
|
||||
if os.path.exists(path):
|
||||
shutil.rmtree(path)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from nkms.db import DB
|
||||
import shutil
|
||||
import pytest
|
||||
|
||||
|
||||
|
@ -19,7 +18,6 @@ def test_db():
|
|||
with pytest.raises(KeyError):
|
||||
db[b'x']
|
||||
assert b'x' not in db
|
||||
db.close()
|
||||
|
||||
assert db.path == db2.path
|
||||
|
||||
shutil.rmtree(db.path)
|
||||
|
|
Loading…
Reference in New Issue