feat: enable parallel pytest-xdist test execution with isolated per-worker databases and data directories
This commit is contained in:
@@ -28,7 +28,9 @@ BASE_URL = f"http://127.0.0.1:{PORT}"
|
||||
|
||||
_TEST_DB = tempfile.NamedTemporaryFile(suffix=f"_{PORT}.db", delete=False)
|
||||
_TEST_DB.close()
|
||||
_TEST_DATA_DIR = Path(tempfile.mkdtemp(suffix=f"_data_{PORT}"))
|
||||
os.environ["DEVPLACE_DATABASE_URL"] = f"sqlite:///{_TEST_DB.name}"
|
||||
os.environ["DEVPLACE_DATA_DIR"] = str(_TEST_DATA_DIR)
|
||||
os.environ["SECRET_KEY"] = "test-secret-key"
|
||||
os.environ["DEVPLACE_DISABLE_SERVICES"] = "1"
|
||||
os.environ["DEVPLACE_RATE_LIMIT"] = "1000000"
|
||||
@@ -102,6 +104,9 @@ def test_db_path():
|
||||
os.unlink(_TEST_DB.name)
|
||||
except OSError:
|
||||
pass
|
||||
import shutil
|
||||
|
||||
shutil.rmtree(_TEST_DATA_DIR, ignore_errors=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
|
||||
Reference in New Issue
Block a user