Posts Tagged: debugging
-
Debugging PytestCollectionWarning: cannot collect test class in pytest 8.0
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'.
-
Debugging RuntimeError: Working Outside of Application Context in Flask 3.0
Resolve Flask 'Working outside of application context' RuntimeError (3.0+): app factories, CLI, tests, extensions. Complete SQLAlchemy examples, pytest, trade-offs.
-
FastAPI Dependency Injection: When Depends() Causes Circular Import Errors
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'.
-
How to Fix 422 Unprocessable Entity Validation Errors in FastAPI Request Bodies
Troubleshooting 422 Unprocessable Entity errors in FastAPI, caused by Pydantic validation failures in request bodies. Covers debugging techniques, common causes like type mismatches and missing fields, and practical solutions including optional fields, unions, validators, and error handling.
-
How to Fix Flaky pytest Tests Caused by Random Order Execution with pytest-randomly
pytest flaky tests random order fix: pytest-randomly shuffles execution order + seeds random, exposes hidden deps. Install pip, demo failing suite, reproduce w/ --randomly-seed=12345, fix w/ autouse fixtures. CI: --randomly-seed=last. Benchmarks detect 80% hidden flakiness. Keywords: 'fix flaky pytest tests', 'pytest-randomly tutorial', 'pytest random order execution', 'pytest flaky random seed', 'detect order dependent tests pytest'.
-
How to Profile Flask Applications with py-spy Without Adding Code Instrumentation
py-spy Flask profiling no code changes: Attach to gunicorn PID, py-spy top reveals 90% CPU in slow endpoint loop, flamegraph.svg export. 5x speedup fixes. Benchmarks: 200req/s → 1000req/s. Keywords: 'profile flask app py-spy', 'flask performance without instrumentation', 'py-spy gunicorn flask', 'flask cpu profiler no decorators'.
-
Identifying Memory Leaks in Long-Running Celery Workers with tracemalloc
Learn how to detect and fix memory leaks in Celery workers using Python's built-in tracemalloc module. Includes signal handlers for production and benchmarks showing RSS growth from 200MB to 2GB.