Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 1, 2024
1 parent e9b389e commit 1628c8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions debug_toolbar/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,6 @@ def _check_async_request(self, request) -> bool:

@staticmethod
def _show_async_request_is_not_supported():
print('-' * 10)
print('Be caution, django-debug-toolbar does not support async requests!')
print('-' * 10)
print("-" * 10)
print("Be caution, django-debug-toolbar does not support async requests!")
print("-" * 10)
17 changes: 10 additions & 7 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,16 +797,17 @@ def test_ajax_refresh(self):


@unittest.skipUnless(
AsyncRequestFactory is not None, "Test valid only for django with async requests"
AsyncRequestFactory is not None, "Test valid only for django with async requests"
)
@override_settings(DEBUG=True)
class DebugToolbarAsyncTestCase(BaseTestCase):

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.async_rf = AsyncRequestFactory()
cls.simple_get_response = lambda *args, **kwargs: HttpResponse("<html><body></body></html>")
cls.simple_get_response = lambda *args, **kwargs: HttpResponse(
"<html><body></body></html>"
)
cls._default_stdout = sys.stdout

def setUp(self):
Expand All @@ -823,14 +824,16 @@ def test_do_not_render_toolbar_if_it_was_async_request(self):
captured_output = io.StringIO()
sys.stdout = captured_output

request = self.async_rf.get('/')
request = self.async_rf.get("/")
response = DebugToolbarMiddleware(self.simple_get_response)(request)

self.assertEqual(response.content, b"<html><body></body></html>")

def test_prints_warning_async_is_not_supported(self):
request = self.async_rf.get('/')
request = self.async_rf.get("/")
DebugToolbarMiddleware(self.simple_get_response)(request)

assert self.captured_output.getvalue() == "----------\nBe caution, django-debug-toolbar does not support async requests!\n----------\n"

assert (
self.captured_output.getvalue()
== "----------\nBe caution, django-debug-toolbar does not support async requests!\n----------\n"
)

0 comments on commit 1628c8f

Please sign in to comment.