diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4feebf7..dbea4c2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -100,11 +100,15 @@ jobs: test_backend: name: Backend Tests - runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: python-version: ["3.9", "3.10", "3.11"] + os: ["ubuntu-20.04"] + include: + - python-version: "3.9" + os: "windows-2022" + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/tests/backend/api_test.py b/tests/backend/api_test.py index 64c989a..72e6d89 100644 --- a/tests/backend/api_test.py +++ b/tests/backend/api_test.py @@ -14,7 +14,8 @@ @pytest.fixture(name="client") def fixture_client(tmp_path: Path) -> Generator[Client, None, None]: - app.config["DATABASE"] = f"sqlite:///{tmp_path}/valens.db" + test_db = tmp_path / "test.db" + app.config["DATABASE"] = f"sqlite:///{test_db}" app.config["SECRET_KEY"] = b"TEST_KEY" app.config["TESTING"] = True diff --git a/tests/backend/assets_test.py b/tests/backend/assets_test.py index 7ac556a..4ca3927 100644 --- a/tests/backend/assets_test.py +++ b/tests/backend/assets_test.py @@ -10,7 +10,8 @@ @pytest.fixture(name="client") def fixture_client(tmp_path: Path) -> Generator[Client, None, None]: - app.config["DATABASE"] = f"sqlite:///{tmp_path}/valens.db" + test_db = tmp_path / "test.db" + app.config["DATABASE"] = f"sqlite:///{test_db}" app.config["SECRET_KEY"] = b"TEST_KEY" app.config["TESTING"] = True diff --git a/tests/backend/demo_test.py b/tests/backend/demo_test.py index 9dc798e..3bde012 100644 --- a/tests/backend/demo_test.py +++ b/tests/backend/demo_test.py @@ -7,4 +7,4 @@ def test_run(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr(app, "run", lambda x, y: None) - demo.run(f"sqlite:///{tmp_path}/db") + demo.run(rf"sqlite:///{tmp_path}/db") diff --git a/tests/conftest.py b/tests/conftest.py index 1b7d5b8..5b7e16a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -19,6 +19,7 @@ def alembic_config() -> dict[str, str]: def alembic_engine() -> object: with NamedTemporaryFile() as tmp_file: app.config["DATABASE"] = f"sqlite:///{tmp_file.name}" + print("XXX", app.config["DATABASE"], repr(app.config["DATABASE"])) with app.app_context(): db.init() yield db.get_engine() diff --git a/tests/e2e/web_test.py b/tests/e2e/web_test.py index 68adbc1..9d564c7 100644 --- a/tests/e2e/web_test.py +++ b/tests/e2e/web_test.py @@ -44,7 +44,7 @@ def _fixture_backend() -> Generator[None, None, None]: config = create_config_file(data_dir, db_file) with app.app_context(): - app.config["DATABASE"] = f"sqlite:///{db_file}" + app.config["DATABASE"] = rf"sqlite:///{db_file}" app.config["SECRET_KEY"] = b"TEST_KEY" tests.utils.init_db_data() diff --git a/valens/config.py b/valens/config.py index 96581c5..ef4556e 100644 --- a/valens/config.py +++ b/valens/config.py @@ -27,7 +27,7 @@ def check_config_file(environ: dict[str, str]) -> None: def create_config_file(config_directory: Path, database_file: Path) -> Path: config = config_directory / "config.py" config.write_text( - f"DATABASE = 'sqlite:///{database_file}'\nSECRET_KEY = {os.urandom(24)!r}\n", + f"DATABASE = r'sqlite:///{database_file}'\nSECRET_KEY = {os.urandom(24)!r}\n", encoding="utf-8", ) return config diff --git a/valens/database.py b/valens/database.py index 6d22381..4f28daf 100644 --- a/valens/database.py +++ b/valens/database.py @@ -32,6 +32,7 @@ def upgrade_lock_file() -> Path: def get_engine() -> Engine: + print("get_engine()", current_app.config["DATABASE"], repr(current_app.config["DATABASE"])) config.check_app_config() db_dir().mkdir(exist_ok=True) return create_engine(current_app.config["DATABASE"])