Skip to content

feat: Add complete Python testing infrastructure with Poetry#3

Open
llbbl wants to merge 1 commit into
pant0m:mainfrom
UnitSeeker:add-testing-infrastructure
Open

feat: Add complete Python testing infrastructure with Poetry#3
llbbl wants to merge 1 commit into
pant0m:mainfrom
UnitSeeker:add-testing-infrastructure

Conversation

@llbbl
Copy link
Copy Markdown

@llbbl llbbl commented Sep 2, 2025

Add Complete Python Testing Infrastructure

Summary

This PR sets up a comprehensive testing infrastructure for the AljcScan security scanning tool using Poetry as the package manager and pytest as the testing framework.

Changes Made

Package Management

  • Created pyproject.toml with Poetry configuration
  • Migrated dependencies from inline imports to proper Poetry dependencies:
    • fake-useragent, termcolor, selenium as production dependencies
    • pytest, pytest-cov, pytest-mock as development dependencies

Testing Configuration

  • Comprehensive pytest configuration with:
    • Test discovery patterns for test_*.py and *_test.py files
    • Coverage reporting in HTML, XML, and terminal formats
    • 30% coverage threshold (adjusted for existing codebase)
    • Custom markers: unit, integration, slow
    • Strict configuration for better test reliability

Directory Structure

tests/
├── __init__.py
├── conftest.py              # Shared fixtures and test utilities
├── unit/
│   └── __init__.py
├── integration/
│   └── __init__.py
└── test_setup_validation.py # Infrastructure validation tests

Shared Testing Utilities (conftest.py)

  • temp_dir: Temporary directory fixture for file operations
  • sample_targets_file: Mock targets.txt for testing
  • sample_rules_file: Mock rules.txt for testing
  • mock_chrome_driver: Mocked Selenium WebDriver
  • mock_subprocess: Mocked subprocess calls
  • mock_user_agent: Mocked UserAgent
  • clean_test_files: Cleanup fixture for test artifacts

Development Workflow

  • Poetry scripts: poetry run test and poetry run tests commands
  • Updated .gitignore: Excludes testing artifacts, coverage reports, and Claude settings
  • Coverage reporting: Generates HTML reports in htmlcov/ and XML in coverage.xml

Running Tests

# Install dependencies
poetry install

# Run all tests
poetry run pytest

# Run tests with coverage
poetry run pytest --cov

# Run only unit tests
poetry run pytest -m unit

# Run tests excluding slow ones
poetry run pytest -m "not slow"

# Generate coverage report
poetry run pytest --cov --cov-report=html

Testing Infrastructure Components

  • Poetry package management with proper dependency separation
  • Pytest testing framework with comprehensive configuration
  • Coverage reporting with multiple output formats
  • Test markers for categorizing test types
  • Shared fixtures for common testing scenarios
  • Validation tests to ensure infrastructure works
  • Proper directory structure for scalable test organization

Notes

  • Coverage threshold set to 30% to accommodate existing codebase
  • Mocking utilities provided for external dependencies (Selenium, subprocess)
  • Test infrastructure is ready for immediate use by developers
  • Poetry lock file included for reproducible dependency resolution

🤖 Generated with Claude Code

- Set up Poetry package manager with pyproject.toml configuration
- Add pytest, pytest-cov, and pytest-mock as dev dependencies
- Configure comprehensive testing settings with 30% coverage threshold
- Create tests/ directory structure with unit/integration subdirectories
- Add shared pytest fixtures in conftest.py for testing utilities
- Update .gitignore with testing artifacts and Claude Code settings
- Include validation tests to verify infrastructure works correctly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant