refactor: consolidate python/tests/ into tests/ directory

Move all Python test files from python/tests/ to the top-level tests/
directory to match the project's CONTRIBUTING.md guidelines. Update
sys.path inserts and template path references to reflect the new
location.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Eugene Mikhantyev
2026-04-12 11:22:39 +01:00
parent c92ca96bac
commit 5de932e2b3
11 changed files with 21 additions and 22 deletions

View File

@@ -7,7 +7,7 @@ python_classes = Test*
python_functions = test_* python_functions = test_*
# Test paths # Test paths
testpaths = tests python/tests testpaths = tests
# Minimum Python version # Minimum Python version
minversion = 6.0 minversion = 6.0

View File

@@ -14,9 +14,9 @@ from typing import Any
import pytest 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 # Inline format (single line) matches what tests previously used
PLACED_RESISTOR_INLINE = """\ PLACED_RESISTOR_INLINE = """\

View File

@@ -17,11 +17,11 @@ import sexpdata
from sexpdata import Symbol from sexpdata import Symbol
# Make python/ importable # 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 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() sch = self._make_schematic()
self._add_resistor(sch, "R1", 100, 100) self._add_resistor(sch, "R1", 100, 100)
# Call handler directly # 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 from kicad_interface import KiCADInterface
iface = KiCADInterface() iface = KiCADInterface()
@@ -541,7 +541,7 @@ class TestMoveWithWirePreservation:
self._add_resistor(sch, "R1", 100, 100) self._add_resistor(sch, "R1", 100, 100)
self._add_wire(sch, 100, 103.81, 100, 120) # wire from pin 1 upward 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 from kicad_interface import KiCADInterface
iface = KiCADInterface() iface = KiCADInterface()
@@ -572,7 +572,7 @@ class TestMoveWithWirePreservation:
self._add_resistor(sch, "R1", 100, 100) self._add_resistor(sch, "R1", 100, 100)
self._add_wire(sch, 50, 50, 60, 50) # unrelated wire 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 from kicad_interface import KiCADInterface
iface = KiCADInterface() iface = KiCADInterface()
@@ -596,7 +596,7 @@ class TestMoveWithWirePreservation:
# Wire from pin 1 to pin 2 of same component (intra-component wire) # Wire from pin 1 to pin 2 of same component (intra-component wire)
self._add_wire(sch, 100, 103.81, 100, 96.19) 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 from kicad_interface import KiCADInterface
iface = KiCADInterface() iface = KiCADInterface()
@@ -621,7 +621,7 @@ class TestMoveWithWirePreservation:
self._add_resistor(sch, "R1", 100, 100) self._add_resistor(sch, "R1", 100, 100)
self._add_wire(sch, 100, 103.81, 100, 120) 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 from kicad_interface import KiCADInterface
iface = KiCADInterface() iface = KiCADInterface()
@@ -648,7 +648,7 @@ class TestMoveWithWirePreservation:
def test_missing_component_returns_error(self) -> None: def test_missing_component_returns_error(self) -> None:
sch = self._make_schematic() 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 from kicad_interface import KiCADInterface
iface = KiCADInterface() iface = KiCADInterface()
@@ -907,7 +907,7 @@ class TestTouchingPinIntegration:
self._add_resistor(sch, "R1", 100, 100) self._add_resistor(sch, "R1", 100, 100)
self._add_resistor(sch, "R2", 100, 92.38) 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 from kicad_interface import KiCADInterface
iface = KiCADInterface() iface = KiCADInterface()
@@ -958,7 +958,7 @@ class TestTouchingPinIntegration:
self._add_resistor(sch, "R1", 100, 100) self._add_resistor(sch, "R1", 100, 100)
self._add_resistor(sch, "R2", 150, 150) # far away 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 from kicad_interface import KiCADInterface
iface = KiCADInterface() iface = KiCADInterface()
@@ -995,7 +995,7 @@ class TestTouchingPinIntegration:
idx = content.rfind(")") idx = content.rfind(")")
sch.write_text(content[:idx] + "\n" + wire_sexp + "\n)", encoding="utf-8") 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 from kicad_interface import KiCADInterface
iface = KiCADInterface() iface = KiCADInterface()

View File

@@ -17,7 +17,7 @@ import sexpdata
from sexpdata import Symbol from sexpdata import Symbol
# Ensure the python/ package is importable # 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 ( from commands.schematic_analysis import (
_aabb_overlap, _aabb_overlap,
@@ -43,7 +43,7 @@ from commands.schematic_analysis import (
# Helpers # 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: def _make_temp_schematic(extra_sexp: str = "") -> Path:

View File

@@ -12,15 +12,14 @@ from typing import Any
import pytest import pytest
# Ensure python/ directory is on path so kicad_interface can be imported # 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 / "python"))
sys.path.insert(0, str(Path(__file__).parent.parent.parent / "python"))
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Helpers shared across tests # 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 # Minimal placed-symbol block we can embed into a schematic for testing
PLACED_RESISTOR_BLOCK = """\ PLACED_RESISTOR_BLOCK = """\

View File

@@ -22,7 +22,7 @@ import sexpdata
# Helpers # Helpers
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
TEMPLATES_DIR = Path(__file__).parent.parent / "templates" TEMPLATES_DIR = Path(__file__).parent.parent / "python" / "templates"
EMPTY_SCH = TEMPLATES_DIR / "empty.kicad_sch" EMPTY_SCH = TEMPLATES_DIR / "empty.kicad_sch"
# Minimal schematic content used by integration tests # Minimal schematic content used by integration tests

View File

@@ -17,7 +17,7 @@ from unittest.mock import MagicMock, patch
import pytest import pytest
# Ensure the python package root is importable # 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 # Module under test

View File

@@ -18,7 +18,7 @@ import sexpdata
from sexpdata import Symbol from sexpdata import Symbol
# Add python dir to path # 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)) sys.path.insert(0, str(PYTHON_DIR))
TEMPLATES_DIR = PYTHON_DIR / "templates" TEMPLATES_DIR = PYTHON_DIR / "templates"