Skip to content

Commit

Permalink
Improve error message for auto_container* fixtures
Browse files Browse the repository at this point in the history
If the user does not add the `auto_container_parametrize` call to
`pytest_generate_tests()` in `conftest.py`, then they get a weird error
message. This commit improves the error message, indicating where the issue
might be.
  • Loading branch information
dcermak committed Dec 18, 2023
1 parent 9319bf5 commit 2f48852
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pytest_container/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ def fixture(
pytest_generate_tests.
"""

container, _ = container_and_marks_from_pytest_param(request.param)
try:
container, _ = container_and_marks_from_pytest_param(request.param)
except AttributeError as attr_err:
raise RuntimeError(
"This fixture was not parametrized correctly, "
"did you forget to call `auto_container_parametrize` in `pytest_generate_tests`?"
) from attr_err
_logger.debug("Requesting the container %s", str(container))

if scope == "session" and container.singleton:
Expand Down

0 comments on commit 2f48852

Please sign in to comment.