Skip to content

Commit bc2acba

Browse files
authored
Disable logging in schemathesis tests (#844)
1 parent 2416bf0 commit bc2acba

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
- [x] Supports `openapi` 3.1+ schema generation out of the box
3737
- [x] Supports all your existing `django` primitives and packages, no custom runtimes
3838
- [x] Great testing tools with [schemathesis](https://github.com/schemathesis/schemathesis), [polyfactory](https://github.com/litestar-org/polyfactory), bundled `pytest` plugin, and default Django's testing primitives
39-
- [x] 100% test coverage with 1700+ of carefully designed unit, integration, and property-based tests
39+
- [x] 100% test coverage with 1900+ of carefully designed unit, integration, and property-based tests
4040
- [x] Built [by the community](https://github.com/wemake-services/django-modern-rest/graphs/contributors) for the community, not a single-person project
4141
- [x] Great docs
4242
- [x] No AI slop, but [built for the LLM era](https://django-modern-rest.readthedocs.io/en/latest/pages/getting-started.html#llms-support)

tests/test_integration/test_contollers/test_user_direct_controller.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def test_user_update_direct_view(dmr_client: DMRClient, faker: Faker) -> None:
1717
'api:controllers:user_update_direct',
1818
kwargs={'user_id': user_id},
1919
),
20-
data={'email': email, 'age': faker.unique.random_int()},
20+
data={'email': email, 'age': faker.unique.random_int(min=1)},
2121
)
2222

23-
assert response.status_code == HTTPStatus.OK
23+
assert response.status_code == HTTPStatus.OK, response.content
2424
assert response.headers['Content-Type'] == 'application/json'
2525
assert response.json() == {
2626
'email': email,
@@ -42,7 +42,7 @@ async def test_user_update_direct_view_async_client(
4242
'api:controllers:user_update_direct',
4343
kwargs={'user_id': user_id},
4444
),
45-
data={'email': email, 'age': faker.unique.random_int()},
45+
data={'email': email, 'age': faker.unique.random_int(min=1)},
4646
)
4747

4848
assert response.status_code == HTTPStatus.OK, response.content

tests/test_integration/test_openapi/test_schema.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import logging
2+
from collections.abc import Iterator
13
from typing import TYPE_CHECKING
24

35
import pytest
@@ -28,6 +30,14 @@ def _patch_response_validation(monkeypatch: pytest.MonkeyPatch) -> None:
2830
)
2931

3032

33+
@pytest.fixture(autouse=True)
34+
def _disable_logging(settings: LazySettings) -> Iterator[None]:
35+
# Logging has too much output with schemathesis:
36+
logging.disable(logging.CRITICAL)
37+
yield
38+
logging.disable(logging.NOTSET)
39+
40+
3141
# The `transactional_db` fixture is required to enable database access.
3242
# When `st.openapi.from_wsgi()` makes a WSGI request, Django's request
3343
# lifecycle triggers database operations.

0 commit comments

Comments
 (0)