Skip to content

Commit 6219140

Browse files
jontsaiclaude
andcommitted
fix: rename tests/vendor to tests/test_vendor to avoid import conflicts
The tests/vendor/ directory was conflicting with src/vendor/ in pytest's import resolution. When pytest added tests/ to sys.path, it would import tests/vendor/__init__.py instead of src/vendor/__init__.py, causing all vendor imports to fail. Renaming to tests/test_vendor/ fixes this conflict and allows tests to run. Also updated test infrastructure: - Enhanced tests/conftest.py with pytest_configure hook - Added README_TESTS.md with instructions for running tests locally - Removed redundant tests/vendor/conftest.py All 6 catalog extra fields tests now pass successfully. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 424f25b commit 6219140

File tree

5 files changed

+73
-7
lines changed

5 files changed

+73
-7
lines changed

README_TESTS.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Running Tests
2+
3+
## Quick Start
4+
5+
The easiest way to run the catalog extra fields tests:
6+
7+
```bash
8+
# Activate virtual environment
9+
source .venv/bin/activate
10+
11+
# Run catalog extra fields tests
12+
python -m pytest tests/test_vendor/test_catalog_v1.py -v
13+
```
14+
15+
## All Test Commands
16+
17+
```bash
18+
# Run all catalog vendor tests
19+
python -m pytest tests/test_vendor/ -v
20+
21+
# Run specific test file
22+
python -m pytest tests/test_vendor/test_catalog_v1.py -v
23+
24+
# Run specific test class
25+
python -m pytest tests/test_vendor/test_catalog_v1.py::TestMetadataExtraFields -v
26+
27+
# Run specific test method
28+
python -m pytest tests/test_vendor/test_catalog_v1.py::TestMetadataExtraFields::test_metadata_accepts_extra_fields -v
29+
30+
# Run with more verbose output
31+
python -m pytest tests/test_vendor/test_catalog_v1.py -vv
32+
33+
# Run and show print statements
34+
python -m pytest tests/test_vendor/test_catalog_v1.py -v -s
35+
36+
# Run all tests in the project
37+
python -m pytest tests/ -v
38+
```
39+
40+
## Using tox (Recommended for full test suite)
41+
42+
The GitHub Actions CI uses tox to run tests across multiple Python and Pydantic versions:
43+
44+
```bash
45+
# Run tests with Python 3.10 and Pydantic 2.10 (no coverage)
46+
python3 -m tox -e py310-pydantic210-nocov
47+
48+
# Run tests with coverage
49+
python3 -m tox -e py310-pydantic210-cover
50+
51+
# Run specific tests with tox
52+
python3 -m tox -e py310-pydantic210-nocov -- tests/test_vendor/test_catalog_v1.py
53+
```
54+
55+
## Continuous Integration
56+
57+
Tests run automatically on every push and pull request via GitHub Actions (`.github/workflows/github-actions.yml`).
58+
59+
The CI runs tests across:
60+
- Python versions: 3.10, 3.11, 3.12, PyPy 3.10
61+
- Pydantic versions: 2.8, 2.10
62+
- With and without coverage reports

tests/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
from pathlib import Path
44

55
# Add src directory to Python path for all tests
6+
# This needs to run at import time, before pytest collects tests
67
src_path = Path(__file__).parent.parent / "src"
78
if str(src_path) not in sys.path:
89
sys.path.insert(0, str(src_path))
10+
11+
12+
def pytest_configure(config):
13+
"""
14+
Hook that runs before test collection.
15+
Ensures src directory is in path before pytest imports test modules.
16+
"""
17+
# Double-check src is in path
18+
if str(src_path) not in sys.path:
19+
sys.path.insert(0, str(src_path))

tests/vendor/conftest.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)