Troubleshooting
This section describes common errors you might encounter working with Testcontainers in the Python environment.
- Error on running tests with pytest:
ScopeMismatch: You tried to access the function scoped fixture event_loop with a session scoped request object, involved factories. -
Problem: the error occurs when you're using asynchronous fixtures with a scope higher than
function, e.g., fixturemoto_containerhassessionscope. The defaultevent_loopfixture provided bypytest-asynciois a function-scoped fixture, so it can't be used with session-scoped fixtures. -
Solution: override the
event_loopfixture with a session-scoped fixture by placing it in your project's defaultconftest.py.