Skip to content

Commit

Permalink
fix(tests): sqlite3.OperationalError: unable to open database file
Browse files Browse the repository at this point in the history
  • Loading branch information
ekkx committed Aug 28, 2024
1 parent bf739f0 commit f0f61a6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tests/test_storage.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import unittest

from yaylib.state import Storage, LocalUser
from yaylib.state import LocalUser, Storage


db_path = os.path.dirname(os.path.dirname(__file__)) + "/.config/test.db"
base_path = os.path.dirname(os.path.dirname(__file__)) + "/.config/tests/"
db_filename = base_path + "test.db"


test_user = LocalUser(
Expand All @@ -19,15 +19,17 @@
class TestStorage(unittest.TestCase):
def setUp(self):
self.clean()
self.storage = Storage(db_path)
if not os.path.exists(base_path):
os.makedirs(base_path)
self.storage = Storage(db_filename)

def tearDown(self):
self.clean()

@staticmethod
def clean():
if os.path.isfile(db_path):
os.remove(db_path)
if os.path.isfile(db_filename):
os.remove(db_filename)

def test_get_user(self):
result = self.storage.create_user(test_user)
Expand Down

0 comments on commit f0f61a6

Please sign in to comment.