fix: Add package installation check and fix test imports (Task 2.1)
Fixes test import errors in 7 test files that failed without package installed. **Changes:** 1. **tests/conftest.py** - Added pytest_configure() hook - Checks if skill_seekers package is installed before running tests - Shows helpful error message guiding users to run `pip install -e .` - Prevents confusing ModuleNotFoundError during test runs 2. **tests/test_constants.py** - Fixed dynamic imports - Changed `from cli import` to `from skill_seekers.cli import` (6 locations) - Fixes imports in test methods that dynamically import modules - All 16 tests now pass ✅ 3. **tests/test_llms_txt_detector.py** - Fixed patch decorators - Changed `patch('cli.llms_txt_detector.` to `patch('skill_seekers.cli.llms_txt_detector.` (4 locations) - All 4 tests now pass ✅ 4. **docs/CLAUDE.md** - Added "Running Tests" section - Clear instructions on installing package before testing - Explanation of why installation is required - Common pytest commands and options - Test coverage statistics **Testing:** - ✅ All 101 tests pass across the 7 affected files: - test_async_scraping.py (11 tests) - test_config_validation.py (26 tests) - test_constants.py (16 tests) - test_estimate_pages.py (8 tests) - test_integration.py (23 tests) - test_llms_txt_detector.py (4 tests) - test_llms_txt_downloader.py (13 tests) - ✅ conftest.py check works correctly - ✅ Helpful error shown when package not installed **Impact:** - Developers now get clear guidance when tests fail due to missing installation - All test import issues resolved - Better developer experience for contributors
This commit is contained in:
@@ -326,6 +326,40 @@ print(soup.select_one('main'))
|
||||
print(soup.select_one('div[role="main"]'))
|
||||
```
|
||||
|
||||
## Running Tests
|
||||
|
||||
**IMPORTANT: You must install the package before running tests**
|
||||
|
||||
```bash
|
||||
# 1. Install package in editable mode (one-time setup)
|
||||
pip install -e .
|
||||
|
||||
# 2. Run all tests
|
||||
pytest
|
||||
|
||||
# 3. Run specific test files
|
||||
pytest tests/test_config_validation.py
|
||||
pytest tests/test_github_scraper.py
|
||||
|
||||
# 4. Run with verbose output
|
||||
pytest -v
|
||||
|
||||
# 5. Run with coverage report
|
||||
pytest --cov=src/skill_seekers --cov-report=html
|
||||
```
|
||||
|
||||
**Why install first?**
|
||||
- Tests import from `skill_seekers.cli` which requires the package to be installed
|
||||
- Modern Python packaging best practice (PEP 517/518)
|
||||
- CI/CD automatically installs with `pip install -e .`
|
||||
- conftest.py will show helpful error if package not installed
|
||||
|
||||
**Test Coverage:**
|
||||
- 391+ tests passing
|
||||
- 39% code coverage
|
||||
- All core features tested
|
||||
- CI/CD tests on Ubuntu + macOS with Python 3.10-3.12
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**No content extracted**: Check `main_content` selector. Common values: `article`, `main`, `div[role="main"]`, `div.content`
|
||||
|
||||
Reference in New Issue
Block a user