41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
import os
|
|
import shutil
|
|
from os import path
|
|
|
|
import pytest
|
|
from core.sheerka.Sheerka import Sheerka
|
|
|
|
from tests.BaseTest import BaseTest
|
|
|
|
|
|
class TestUsingFileBasedSheerka(BaseTest):
|
|
tests_root = path.abspath("../../build/tests")
|
|
root_folder = "init_folder"
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def init_test(self):
|
|
if path.exists(self.tests_root):
|
|
shutil.rmtree(self.tests_root)
|
|
|
|
if not path.exists(self.tests_root):
|
|
os.makedirs(self.tests_root)
|
|
current_pwd = os.getcwd()
|
|
os.chdir(self.tests_root)
|
|
|
|
yield None
|
|
|
|
os.chdir(current_pwd)
|
|
|
|
def get_sheerka(self, **kwargs):
|
|
|
|
# use dictionary based io instead of file
|
|
# If you do so, information between two different instances of sheerka
|
|
# won't be shared
|
|
use_dict = kwargs.get("use_dict", False)
|
|
|
|
root = "mem://" if use_dict else self.root_folder
|
|
sheerka = Sheerka()
|
|
sheerka.initialize(root, save_execution_context=False)
|
|
|
|
return sheerka
|