]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Black formatting 29/head
authorTom Christie <tom@tomchristie.com>
Wed, 18 Jul 2018 12:08:06 +0000 (13:08 +0100)
committerTom Christie <tom@tomchristie.com>
Wed, 18 Jul 2018 12:08:06 +0000 (13:08 +0100)
starlette/debug.py
tests/test_debug.py

index b8d9334033277e7159f511b83afe8e1ab8d6ea5b..d40c6d3f2a5ec45b51c01d5e87fc9be92648fc6d 100644 (file)
@@ -25,11 +25,11 @@ class _DebugResponder:
         except:
             if self.response_started:
                 raise
-            headers = Headers(self.scope.get('headers', []))
-            accept = headers.get('accept', '')
-            if 'text/html' in accept:
+            headers = Headers(self.scope.get("headers", []))
+            accept = headers.get("accept", "")
+            if "text/html" in accept:
                 exc_html = html.escape(traceback.format_exc())
-                content = f'<html><body><h1>500 Server Error</h1><pre>{exc_html}</pre></body></html>'
+                content = f"<html><body><h1>500 Server Error</h1><pre>{exc_html}</pre></body></html>"
                 response = HTMLResponse(content, status_code=500)
             else:
                 content = traceback.format_exc()
@@ -37,6 +37,6 @@ class _DebugResponder:
             await response(receive, send)
 
     async def send(self, message):
-        if message['type'] == 'http.response.start':
+        if message["type"] == "http.response.start":
             self.response_started = True
         await self.raw_send(message)
index 4cff1120c2a3351a31df2686ddf3c27626d36254..8694bb091547326c115aae74a779a67a799a77c5 100644 (file)
@@ -6,35 +6,38 @@ import pytest
 def test_debug_text():
     def app(scope):
         async def asgi(receive, send):
-            raise RuntimeError('Something went wrong')
+            raise RuntimeError("Something went wrong")
+
         return asgi
 
     client = TestClient(DebugMiddleware(app))
     response = client.get("/")
     assert response.status_code == 500
-    assert response.headers['content-type'].startswith('text/plain')
-    assert 'RuntimeError' in response.text
+    assert response.headers["content-type"].startswith("text/plain")
+    assert "RuntimeError" in response.text
 
 
 def test_debug_html():
     def app(scope):
         async def asgi(receive, send):
-            raise RuntimeError('Something went wrong')
+            raise RuntimeError("Something went wrong")
+
         return asgi
 
     client = TestClient(DebugMiddleware(app))
-    response = client.get("/", headers={'Accept': 'text/html, */*'})
+    response = client.get("/", headers={"Accept": "text/html, */*"})
     assert response.status_code == 500
-    assert response.headers['content-type'].startswith('text/html')
-    assert 'RuntimeError' in response.text
+    assert response.headers["content-type"].startswith("text/html")
+    assert "RuntimeError" in response.text
 
 
 def test_debug_after_response_sent():
     def app(scope):
         async def asgi(receive, send):
-            response = Response(b'', status_code=204)
+            response = Response(b"", status_code=204)
             await response(receive, send)
-            raise RuntimeError('Something went wrong')
+            raise RuntimeError("Something went wrong")
+
         return asgi
 
     client = TestClient(DebugMiddleware(app))