Python Testing: pytest, unittest, tox, and coverage.py Compared
Compare unittest (stdlib) with pytest, tox for multi-environment testing, and coverage.py. Practical examples, configurations, benchmarks on simple tests, and integration tips.
The go-to resource for upgrading Python, Django, Flask, and your dependencies.
70 articles on upgrading Python, Django, Flask, and managing dependencies
Compare unittest (stdlib) with pytest, tox for multi-environment testing, and coverage.py. Practical examples, configurations, benchmarks on simple tests, and integration tips.
Benchmarks comparing Pandas and Polars on groupby, filter, and join operations with 1 million rows. Polars shows significant speedups in some cases. Keywords: pandas polars performance comparison, dataframe benchmarks, python data processing.
Learn how to implement Redis caching for Flask-SQLAlchemy queries to reduce database load and improve response times. This tutorial covers key hashing, TTL management, and invalidation strategies.
uv pip sync synchronizes Python environments exactly to requirements.txt, removing unused packages for reproducibility. Works on system Python without virtualenvs for tools/scripts. Includes setup, usage, lockfiles, benchmarks, comparisons to pip-tools/Poetry.
Fix broken virtual environments caused by asdf .tool-versions switching Python versions globally vs locally. Step-by-step guide to diagnose and resolve venv issues with asdf Python plugin.
Learn how to install and manage multiple Python versions on Ubuntu 24.04 LTS using asdf-vm's Python plugin. Step-by-step commands tested on fresh installs.
Fix 'asdf reshim' errors after pip install like permission denied, missing shims, PATH issues. 10 common problems with step-by-step solutions for Python devs using asdf.
Compare asyncio and multiprocessing performance for CPU-bound tasks like fibonacci and matrix multiplication. Benchmarks on Python 3.12 vs 3.13 free-threaded show multiprocessing's edge and how no-GIL threading closes the gap.
Audit Flask 3.0 dependencies for OWASP Top 10 A06 vulnerabilities using pip-audit, poetry audit, and safety CLI. Covers detection, fixes, and CI/CD integration for Werkzeug, Jinja2, and other deps.
Step-by-step guide to convert Poetry's poetry.lock to pip-compatible requirements.txt for legacy CI/CD pipelines like Jenkins, Travis CI, or GitLab that lack Poetry support. Ensure reproducible Python dependency installs without version drift.
Uncover why coverage.py reports 100% line coverage while missing critical branches in if/else and loops. Enable branch coverage, integrate with pytest/tox, use pragmas, generate HTML reports, and review benchmarks.
CVE-2024-XXXXX in requests 2.31.0 enables SSRF via malformed URLs. Mitigation: upgrade to 2.32+, lock dependencies with uv or pip-tools, audit with pip-audit or Safety.
PytestCollectionWarning cannot collect test class pytest 8.0 fix: abstract classes, staticmethod parametrize, multiple inheritance, empty Test classes. Migration guide, code examples, pytestmark.skipif(inspect.isabstract). Keywords: 'PytestCollectionWarning pytest 8', 'cannot collect test class pytest', 'pytest 8 collection changes', 'fix pytest abstract test class warning'.
Resolve Flask 'Working outside of application context' RuntimeError (3.0+): app factories, CLI, tests, extensions. Complete SQLAlchemy examples, pytest, trade-offs.
Master Python dependency management: Compare pip with requirements.txt, Poetry for locked reproducible environments, and ultrafast uv resolver/installer. Best practices, comparisons, and migration guides for 2026 Python projects.
Detect typosquatting PyPI packages mimicking requests urllib3 pillow: low downloads, suspicious uploaders, few versions. Python supply chain security script queries PyPI API/stats, flags risks. Prevent supply-chain attacks – actionable audit steps, CI integration.
FastAPI 0.115-0.120 migration: Replace deprecated @app.on_event('startup'/'shutdown') with lifespan=asynccontextmanager(app). DB pools, ML models, uvicorn reload safe. Code before/after, pytest verify. Targets 'fastapi lifespan migration', 'fastapi startup shutdown deprecated', 'fastapi 0.115 lifespan events'.
FastAPI BackgroundTasks vs Celery for async email sending: Zero-setup fire-and-forget vs distributed queues. Benchmarks show BackgroundTasks add 1.2ms latency for 200ms emails (non-blocking). Celery excels at retries, scaling to 10k+/min. Code examples, Redis setup, when to choose each. Keywords: 'fastapi background tasks celery', 'fastapi async email celery', 'backgroundtasks vs celery fastapi', 'fastapi email background'.
FastAPI Depends() circular import errors fix: Move to central deps.py, string refs Depends('get_db'), lazy imports in func, app factories. Common router→model→db cycles. Code + pytest verification. Targets 'fastapi circular import depends', 'fastapi dependency injection error', 'ImportError partially initialized module fastapi'.
FastAPI tutorial: installation, hello world app, Pydantic models, databases, dependencies, testing, deployment. Benchmarks vs Flask and Django.
Need help maintaining or upgrading your Python application? Durable Programming specializes in keeping Python apps secure, performant, and up-to-date.
Hire Durable Programming