Skip to content

feat: Add comprehensive Python testing infrastructure with Poetry #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

llbbl
Copy link

@llbbl llbbl commented Jun 16, 2025

Add Python Testing Infrastructure

Summary

This PR sets up a complete testing infrastructure for the Discord bot project using Poetry as the package manager and pytest as the testing framework. The setup provides a ready-to-use testing environment where developers can immediately start writing tests.

Changes Made

Package Management

  • Introduced Poetry as the package manager
  • Created pyproject.toml with project configuration
  • Migrated existing dependencies from requirements.txt
  • Added development dependencies for testing

Testing Framework

  • pytest - Main testing framework
  • pytest-cov - Coverage reporting with 80% threshold
  • pytest-mock - Mocking utilities
  • pytest-asyncio - Async test support

Configuration

  • Configured pytest in pyproject.toml with:
    • Test discovery patterns
    • Coverage settings (HTML, XML, terminal reports)
    • Custom markers (unit, integration, slow)
    • Strict mode and verbose output

Directory Structure

tests/
├── __init__.py
├── conftest.py           # Shared fixtures
├── test_setup_validation.py  # Validation tests
├── unit/
│   └── __init__.py
└── integration/
    └── __init__.py

Test Fixtures

Created comprehensive Discord.py fixtures in conftest.py:

  • mock_bot - Mock Discord bot instance
  • mock_ctx - Mock command context
  • mock_member - Mock Discord member
  • mock_role - Mock Discord role
  • mock_message - Mock Discord message
  • mock_embed - Mock Discord embed
  • mock_database - Mock database connection
  • mock_config - Mock configuration
  • temp_dir - Temporary directory for tests

Additional Updates

  • Updated .gitignore to include .claude/*
  • Created validation tests to verify the infrastructure works

Running Tests

To run tests, use either of these commands:

# Install dependencies first
poetry install

# Run all tests
poetry run pytest

# Run with specific options
poetry run pytest -v --no-cov  # Verbose without coverage
poetry run pytest tests/unit/   # Run only unit tests
poetry run pytest -m integration  # Run only integration tests

Notes

  • The coverage threshold is set to 80% by default
  • Coverage reports are generated in HTML (htmlcov/) and XML (coverage.xml) formats
  • The validation tests ensure all fixtures and testing infrastructure work correctly
  • No actual unit tests for the codebase were written - this PR only sets up the infrastructure

- Set up Poetry as package manager and migrate from requirements.txt
- Add pytest, pytest-cov, pytest-mock, and pytest-asyncio dependencies
- Configure pytest with coverage reporting (80% threshold)
- Create test directory structure with unit/integration subdirectories
- Add comprehensive Discord.py test fixtures in conftest.py
- Include validation tests to verify setup functionality
- Update .gitignore with Claude settings entry
@kkrypt0nn kkrypt0nn closed this Jun 16, 2025
@kkrypt0nn kkrypt0nn added the spam This issue/PR is spam label Jun 16, 2025
@kkrypt0nn
Copy link
Owner

I won't review or accept AI-generated slop code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spam This issue/PR is spam
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants