Merge pull request #91 from mixelpixx/refactor/consolidate-tests-directory
refactor: consolidate Python tests into single tests/ directory
This commit is contained in:
@@ -7,7 +7,7 @@ python_classes = Test*
|
||||
python_functions = test_*
|
||||
|
||||
# Test paths
|
||||
testpaths = tests python/tests
|
||||
testpaths = tests
|
||||
|
||||
# Minimum Python version
|
||||
minversion = 6.0
|
||||
|
||||
@@ -14,9 +14,9 @@ from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent / "python"))
|
||||
|
||||
TEMPLATE_SCH = Path(__file__).parent.parent / "templates" / "empty.kicad_sch"
|
||||
TEMPLATE_SCH = Path(__file__).parent.parent / "python" / "templates" / "empty.kicad_sch"
|
||||
|
||||
# Inline format (single line) – matches what tests previously used
|
||||
PLACED_RESISTOR_INLINE = """\
|
||||
@@ -17,11 +17,11 @@ import sexpdata
|
||||
from sexpdata import Symbol
|
||||
|
||||
# Make python/ importable
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "python"))
|
||||
|
||||
from commands.wire_dragger import EPS, WireDragger, _coords_match, _rotate
|
||||
|
||||
TEMPLATE_PATH = Path(__file__).resolve().parent.parent / "templates" / "empty.kicad_sch"
|
||||
TEMPLATE_PATH = Path(__file__).resolve().parent.parent / "python" / "templates" / "empty.kicad_sch"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -517,7 +517,7 @@ class TestMoveWithWirePreservation:
|
||||
sch = self._make_schematic()
|
||||
self._add_resistor(sch, "R1", 100, 100)
|
||||
# Call handler directly
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "python"))
|
||||
from kicad_interface import KiCADInterface
|
||||
|
||||
iface = KiCADInterface()
|
||||
@@ -541,7 +541,7 @@ class TestMoveWithWirePreservation:
|
||||
self._add_resistor(sch, "R1", 100, 100)
|
||||
self._add_wire(sch, 100, 103.81, 100, 120) # wire from pin 1 upward
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "python"))
|
||||
from kicad_interface import KiCADInterface
|
||||
|
||||
iface = KiCADInterface()
|
||||
@@ -572,7 +572,7 @@ class TestMoveWithWirePreservation:
|
||||
self._add_resistor(sch, "R1", 100, 100)
|
||||
self._add_wire(sch, 50, 50, 60, 50) # unrelated wire
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "python"))
|
||||
from kicad_interface import KiCADInterface
|
||||
|
||||
iface = KiCADInterface()
|
||||
@@ -596,7 +596,7 @@ class TestMoveWithWirePreservation:
|
||||
# Wire from pin 1 to pin 2 of same component (intra-component wire)
|
||||
self._add_wire(sch, 100, 103.81, 100, 96.19)
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "python"))
|
||||
from kicad_interface import KiCADInterface
|
||||
|
||||
iface = KiCADInterface()
|
||||
@@ -621,7 +621,7 @@ class TestMoveWithWirePreservation:
|
||||
self._add_resistor(sch, "R1", 100, 100)
|
||||
self._add_wire(sch, 100, 103.81, 100, 120)
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "python"))
|
||||
from kicad_interface import KiCADInterface
|
||||
|
||||
iface = KiCADInterface()
|
||||
@@ -648,7 +648,7 @@ class TestMoveWithWirePreservation:
|
||||
|
||||
def test_missing_component_returns_error(self) -> None:
|
||||
sch = self._make_schematic()
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "python"))
|
||||
from kicad_interface import KiCADInterface
|
||||
|
||||
iface = KiCADInterface()
|
||||
@@ -907,7 +907,7 @@ class TestTouchingPinIntegration:
|
||||
self._add_resistor(sch, "R1", 100, 100)
|
||||
self._add_resistor(sch, "R2", 100, 92.38)
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "python"))
|
||||
from kicad_interface import KiCADInterface
|
||||
|
||||
iface = KiCADInterface()
|
||||
@@ -958,7 +958,7 @@ class TestTouchingPinIntegration:
|
||||
self._add_resistor(sch, "R1", 100, 100)
|
||||
self._add_resistor(sch, "R2", 150, 150) # far away
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "python"))
|
||||
from kicad_interface import KiCADInterface
|
||||
|
||||
iface = KiCADInterface()
|
||||
@@ -995,7 +995,7 @@ class TestTouchingPinIntegration:
|
||||
idx = content.rfind(")")
|
||||
sch.write_text(content[:idx] + "\n" + wire_sexp + "\n)", encoding="utf-8")
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "python"))
|
||||
from kicad_interface import KiCADInterface
|
||||
|
||||
iface = KiCADInterface()
|
||||
@@ -17,7 +17,7 @@ import sexpdata
|
||||
from sexpdata import Symbol
|
||||
|
||||
# Ensure the python/ package is importable
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "python"))
|
||||
|
||||
from commands.schematic_analysis import (
|
||||
_aabb_overlap,
|
||||
@@ -43,7 +43,7 @@ from commands.schematic_analysis import (
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
TEMPLATE_PATH = Path(__file__).resolve().parent.parent / "templates" / "empty.kicad_sch"
|
||||
TEMPLATE_PATH = Path(__file__).resolve().parent.parent / "python" / "templates" / "empty.kicad_sch"
|
||||
|
||||
|
||||
def _make_temp_schematic(extra_sexp: str = "") -> Path:
|
||||
@@ -12,15 +12,14 @@ from typing import Any
|
||||
import pytest
|
||||
|
||||
# Ensure python/ directory is on path so kicad_interface can be imported
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent.parent / "python"))
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent / "python"))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers shared across tests
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
TEMPLATE_SCH = Path(__file__).parent.parent / "templates" / "empty.kicad_sch"
|
||||
TEMPLATE_SCH = Path(__file__).parent.parent / "python" / "templates" / "empty.kicad_sch"
|
||||
|
||||
# Minimal placed-symbol block we can embed into a schematic for testing
|
||||
PLACED_RESISTOR_BLOCK = """\
|
||||
@@ -22,7 +22,7 @@ import sexpdata
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
TEMPLATES_DIR = Path(__file__).parent.parent / "templates"
|
||||
TEMPLATES_DIR = Path(__file__).parent.parent / "python" / "templates"
|
||||
EMPTY_SCH = TEMPLATES_DIR / "empty.kicad_sch"
|
||||
|
||||
# Minimal schematic content used by integration tests
|
||||
@@ -17,7 +17,7 @@ from unittest.mock import MagicMock, patch
|
||||
import pytest
|
||||
|
||||
# Ensure the python package root is importable
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent / "python"))
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Module under test
|
||||
@@ -18,7 +18,7 @@ import sexpdata
|
||||
from sexpdata import Symbol
|
||||
|
||||
# Add python dir to path
|
||||
PYTHON_DIR = Path(__file__).parent.parent
|
||||
PYTHON_DIR = Path(__file__).parent.parent / "python"
|
||||
sys.path.insert(0, str(PYTHON_DIR))
|
||||
|
||||
TEMPLATES_DIR = PYTHON_DIR / "templates"
|
||||
Reference in New Issue
Block a user