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.
This should make it easier to spot issues like
#179 easier.
  • Loading branch information
dcermak committed Dec 18, 2023
1 parent 9319bf5 commit 605c7df
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(

Check warning on line 82 in pytest_container/plugin.py

View check run for this annotation

Codecov / codecov/patch

pytest_container/plugin.py#L81-L82

Added lines #L81 - L82 were not covered by tests
"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 605c7df

Please sign in to comment.