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:
@@ -109,14 +109,14 @@ class TestConstantsUsage(unittest.TestCase):
|
||||
|
||||
def test_doc_scraper_imports_constants(self):
|
||||
"""Test that doc_scraper imports and uses constants."""
|
||||
from cli import doc_scraper
|
||||
from skill_seekers.cli import doc_scraper
|
||||
# Check that doc_scraper can access the constants
|
||||
self.assertTrue(hasattr(doc_scraper, 'DEFAULT_RATE_LIMIT'))
|
||||
self.assertTrue(hasattr(doc_scraper, 'DEFAULT_MAX_PAGES'))
|
||||
|
||||
def test_estimate_pages_imports_constants(self):
|
||||
"""Test that estimate_pages imports and uses constants."""
|
||||
from cli import estimate_pages
|
||||
from skill_seekers.cli import estimate_pages
|
||||
# Verify function signature uses constants
|
||||
import inspect
|
||||
sig = inspect.signature(estimate_pages.estimate_pages)
|
||||
@@ -125,7 +125,7 @@ class TestConstantsUsage(unittest.TestCase):
|
||||
def test_enhance_skill_imports_constants(self):
|
||||
"""Test that enhance_skill imports constants."""
|
||||
try:
|
||||
from cli import enhance_skill
|
||||
from skill_seekers.cli import enhance_skill
|
||||
# Check module loads without errors
|
||||
self.assertIsNotNone(enhance_skill)
|
||||
except (ImportError, SystemExit) as e:
|
||||
@@ -135,7 +135,7 @@ class TestConstantsUsage(unittest.TestCase):
|
||||
|
||||
def test_enhance_skill_local_imports_constants(self):
|
||||
"""Test that enhance_skill_local imports constants."""
|
||||
from cli import enhance_skill_local
|
||||
from skill_seekers.cli import enhance_skill_local
|
||||
self.assertIsNotNone(enhance_skill_local)
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ class TestConstantsExports(unittest.TestCase):
|
||||
|
||||
def test_all_exports_exist(self):
|
||||
"""Test that all items in __all__ exist."""
|
||||
from cli import constants
|
||||
from skill_seekers.cli import constants
|
||||
self.assertTrue(hasattr(constants, '__all__'))
|
||||
for name in constants.__all__:
|
||||
self.assertTrue(
|
||||
@@ -154,7 +154,7 @@ class TestConstantsExports(unittest.TestCase):
|
||||
|
||||
def test_all_exports_count(self):
|
||||
"""Test that __all__ has expected number of exports."""
|
||||
from cli import constants
|
||||
from skill_seekers.cli import constants
|
||||
# We defined 18 constants (added DEFAULT_ASYNC_MODE)
|
||||
self.assertEqual(len(constants.__all__), 18)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user