Fix CI errors: linting, type checking, and tests
- Fix import sorting in test_instruments.py (ruff I001) - Install pandas-stubs for mypy type checking - Add garbage collection cleanup to repository test fixtures - Prevent Windows file locking errors in tempfile cleanup All CI checks now passing: lint, type check, and all 244 tests.
This commit is contained in:
@@ -8,11 +8,11 @@ import pytest
|
|||||||
|
|
||||||
from py_dvt_ate.instruments import (
|
from py_dvt_ate.instruments import (
|
||||||
IMultimeter,
|
IMultimeter,
|
||||||
IPowerSupply,
|
|
||||||
IThermalChamber,
|
|
||||||
InstrumentConfig,
|
InstrumentConfig,
|
||||||
InstrumentFactory,
|
InstrumentFactory,
|
||||||
InstrumentSet,
|
InstrumentSet,
|
||||||
|
IPowerSupply,
|
||||||
|
IThermalChamber,
|
||||||
)
|
)
|
||||||
from py_dvt_ate.instruments.drivers import (
|
from py_dvt_ate.instruments.drivers import (
|
||||||
MultimeterDriver,
|
MultimeterDriver,
|
||||||
|
|||||||
@@ -22,7 +22,13 @@ def temp_db():
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def repository(temp_db):
|
def repository(temp_db):
|
||||||
"""Create a repository instance for testing."""
|
"""Create a repository instance for testing."""
|
||||||
return SQLiteRepository(temp_db)
|
import gc
|
||||||
|
repo = SQLiteRepository(temp_db)
|
||||||
|
yield repo
|
||||||
|
# Ensure all connections and file handles are closed before cleanup
|
||||||
|
# This is critical on Windows to prevent PermissionError
|
||||||
|
del repo
|
||||||
|
gc.collect()
|
||||||
|
|
||||||
|
|
||||||
def test_create_run(repository):
|
def test_create_run(repository):
|
||||||
@@ -235,6 +241,7 @@ def test_multiple_results(repository):
|
|||||||
|
|
||||||
def test_custom_measurements_dir(temp_db):
|
def test_custom_measurements_dir(temp_db):
|
||||||
"""Test using a custom measurements directory."""
|
"""Test using a custom measurements directory."""
|
||||||
|
import gc
|
||||||
with tempfile.TemporaryDirectory() as tmpdir:
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
measurements_dir = Path(tmpdir) / "custom_measurements"
|
measurements_dir = Path(tmpdir) / "custom_measurements"
|
||||||
repo = SQLiteRepository(temp_db, measurements_dir=measurements_dir)
|
repo = SQLiteRepository(temp_db, measurements_dir=measurements_dir)
|
||||||
@@ -254,6 +261,10 @@ def test_custom_measurements_dir(temp_db):
|
|||||||
expected_path = measurements_dir / f"run_{run_id}" / "measurements.parquet"
|
expected_path = measurements_dir / f"run_{run_id}" / "measurements.parquet"
|
||||||
assert expected_path.exists()
|
assert expected_path.exists()
|
||||||
|
|
||||||
|
# Clean up repository before temp directory cleanup
|
||||||
|
del repo
|
||||||
|
gc.collect()
|
||||||
|
|
||||||
|
|
||||||
def test_parquet_schema(repository):
|
def test_parquet_schema(repository):
|
||||||
"""Test that Parquet file has correct schema."""
|
"""Test that Parquet file has correct schema."""
|
||||||
|
|||||||
Reference in New Issue
Block a user