Open Veritogen opened 4 months ago
It happens due to a return statement in pytest-monitor.py where instead should be a raise. I'm currently fixing it and will post a pull request in a minute.
I had to refactor again and ran into some trouble with git (tried to reset an upstream branch I did the PR on) so I had to open a new PR.
If I just changed the line to raise the exception instead of returning it, the test runs ended in an endless loop when monitoring was turned on, so I kept the return statement instead and did the exception handling with the return value of wrapped_function()
(line 216 in pytest_monitor.py) on the parent context (caller of wrapped_function()
in the if branch).
Describe the bug When we add
--no-monitor
to thepytest.ini
like soaddopts = --no-monitor
,pytest.raises
,django_assert_num_queries
anddjango_assert_max_num_queries
(the latter two are provided bypytest-django
) do not work anymore. They should be raising test failures.To Reproduce Steps to reproduce the behavior:
--no-monitor
=> all tests pass--no-monitor
=> all tests failfrom books.models import Book
def test_raise_exception(): with pytest.raises(Exception): x = 1 / 1
def test_query_assertion(django_assert_num_queries, db): with django_assert_num_queries(0): print(Book.objects.all())
def test_max_queries_assertion(django_assert_max_num_queries, db): with django_assert_max_num_queries(0): print(Book.objects.all())