# Configuración de Tox para testing multi-entorno # Sistema de Asistencia MAC [tox] # Entornos a ejecutar por defecto envlist = py311-django52 lint format-check type-check security coverage # Requiere Python 3.11+ minversion = 4.0 skipsdist = True [testenv] # Configuración base para todos los entornos setenv = PYTHONPATH = {toxinidir} DJANGO_SETTINGS_MODULE = mac_attendance.settings DEBUG = False SECRET_KEY = test-secret-key-for-tox DB_ENGINE = postgresql DB_NAME = test_mac_attendance DB_USER = mac_user DB_PASSWORD = mac_password_2024_secure DB_HOST = localhost DB_PORT = 5432 passenv = CI POSTGRES_* DB_* deps = -r{toxinidir}/requirements.txt -r{toxinidir}/requirements-dev.txt # Entorno principal: Tests con pytest [testenv:py311-django52] description = Run tests with Python 3.11 and Django 5.2 commands = pytest {posargs:--cov=. --cov-report=html --cov-report=term-missing} [testenv:test] description = Run tests quickly (alias) commands = pytest {posargs} [testenv:test-fast] description = Run tests without coverage (faster) commands = pytest {posargs:--no-cov} # Linting y formateo [testenv:lint] description = Run all linters (flake8, pylint) commands = flake8 {posargs:.} pylint {posargs:authentication attendance events mac_attendance} [testenv:format] description = Format code with black and isort commands = black {posargs:.} isort {posargs:.} [testenv:format-check] description = Check code formatting without modifying commands = black --check --diff {posargs:.} isort --check-only --diff {posargs:.} # Type checking [testenv:type-check] description = Run mypy type checker commands = mypy {posargs:.} # Seguridad [testenv:security] description = Run security checks commands = bandit -r {posargs:authentication attendance events mac_attendance} -ll safety check --json [testenv:security-full] description = Run comprehensive security audit commands = bandit -r . -ll -f json -o bandit-report.json safety check --full-report # Cobertura [testenv:coverage] description = Generate coverage reports commands = coverage run -m pytest coverage report -m coverage html coverage xml [testenv:coverage-report] description = Show coverage report commands = coverage report -m # Métricas de código [testenv:metrics] description = Generate code metrics commands = radon cc {posargs:. --min B} radon mi {posargs:. --min B} [testenv:complexity] description = Check code complexity commands = radon cc . --total-average --show-complexity # Documentación [testenv:docs] description = Generate documentation (placeholder) commands = python -c "print('Documentation generation not configured yet')" # Entorno limpio [testenv:clean] description = Clean up generated files allowlist_externals = rm find commands = find . -type d -name __pycache__ -exec rm -rf {{}} + find . -type f -name '*.pyc' -delete find . -type f -name '*.pyo' -delete rm -rf .pytest_cache .mypy_cache .tox htmlcov .coverage coverage.xml # Configuración de herramientas [flake8] max-line-length = 120 exclude = .git, __pycache__, */migrations/*, */venv/*, */env/*, .venv, .tox, dist, build, staticfiles, media ignore = E203, # whitespace before ':' E266, # too many leading '#' for block comment E501, # line too long (handled by black) W503, # line break before binary operator W504, # line break after binary operator max-complexity = 10 [pytest] DJANGO_SETTINGS_MODULE = mac_attendance.settings python_files = tests.py test_*.py *_tests.py addopts = --verbose --strict-markers --tb=short testpaths = tests markers = slow: marks tests as slow integration: marks tests as integration tests unit: marks tests as unit tests [coverage:run] source = . omit = */migrations/* */tests/* */test_*.py */__pycache__/* */venv/* */env/* .venv/* manage.py */wsgi.py */asgi.py [coverage:report] precision = 2 show_missing = True skip_covered = False