1import pathlib 2import sys 3import unittest.mock as mock 4 5import pytest 6 7 8@pytest.fixture(autouse=True, scope="session") 9def tpath(): 10 code_dir = pathlib.Path(__file__).parent.parent.absolute() 11 assert code_dir.exists() 12 13 tpath_dir = code_dir / "tests" / "tpath" 14 assert tpath_dir.exists() 15 16 NEW_PATH = [str(code_dir), str(tpath_dir)] 17 18 for p in sys.path: 19 if p not in NEW_PATH: 20 NEW_PATH.append(p) 21 22 with mock.patch("sys.path", NEW_PATH): 23 yield 24