@@ -58,7 +58,9 @@ def test_middleware_logs_successfully(
5858
5959 middleware .log (scope , info ) # type: ignore # pylint: disable=W0212:protected-access
6060
61- logs_at_correct_log_level = [record for record in caplog .records if record .levelno == log_level ]
61+ logs_at_correct_log_level = [
62+ record for record in caplog .records if record .levelno == log_level
63+ ]
6264
6365 assert len (caplog .records ) == 1
6466 assert len (logs_at_correct_log_level ) == 1
@@ -84,7 +86,11 @@ def test_logs_can_be_ignored_via_path_and_header(
8486 excluded_paths = ["maintain/serviceStatus" , "health/serviceStatus" ]
8587 mock_app : ASGI3Application = lambda scope , receive , send : None # type: ignore # noqa: E731
8688 middleware = FilteredAccessLoggerMiddleware (
87- app = mock_app , format = None , logger = None , excluded_paths = excluded_paths , exclude_header = exclude_header
89+ app = mock_app ,
90+ format = None ,
91+ logger = None ,
92+ excluded_paths = excluded_paths ,
93+ exclude_header = exclude_header ,
8894 )
8995
9096 scope = {"type" : "http" , "path" : path , "headers" : ignored_headers }
@@ -122,8 +128,13 @@ def test_excluding_log_via_path_is_possible(path: str, pathIsIgnored: bool) -> N
122128 assert actual == pathIsIgnored
123129
124130
125- @pytest .mark .parametrize ("path,pathIsIgnored" , [("/serviceStatus" , False ), ("/my/other/endpoint" , False ), ("/" , False )])
126- def test_not_configured_excluded_paths_does_not_cause_any_logs_to_be_excluded (path : str , pathIsIgnored : bool ) -> None :
131+ @pytest .mark .parametrize (
132+ "path,pathIsIgnored" ,
133+ [("/serviceStatus" , False ), ("/my/other/endpoint" , False ), ("/" , False )],
134+ )
135+ def test_not_configured_excluded_paths_does_not_cause_any_logs_to_be_excluded (
136+ path : str , pathIsIgnored : bool
137+ ) -> None :
127138 excluded_paths = None
128139 scope = {"path" : path }
129140
@@ -133,8 +144,13 @@ def test_not_configured_excluded_paths_does_not_cause_any_logs_to_be_excluded(pa
133144 assert actual == pathIsIgnored
134145
135146
136- @pytest .mark .parametrize ("path,pathIsIgnored" , [("/serviceStatus" , False ), ("/my/other/endpoint" , False ), ("/" , False )])
137- def test_empty_excludes_paths_does_not_cause_any_logs_to_be_excluded (path : str , pathIsIgnored : bool ) -> None :
147+ @pytest .mark .parametrize (
148+ "path,pathIsIgnored" ,
149+ [("/serviceStatus" , False ), ("/my/other/endpoint" , False ), ("/" , False )],
150+ )
151+ def test_empty_excludes_paths_does_not_cause_any_logs_to_be_excluded (
152+ path : str , pathIsIgnored : bool
153+ ) -> None :
138154 excluded_paths : List [str ] = []
139155 scope = {"path" : path }
140156
@@ -154,26 +170,34 @@ def test_empty_excludes_paths_does_not_cause_any_logs_to_be_excluded(path: str,
154170 ([], False ),
155171 ],
156172)
157- def test_excluding_logs_via_header_is_possible (headers : list [tuple [bytes , bytes ]], path_is_ignored : bool ) -> None :
173+ def test_excluding_logs_via_header_is_possible (
174+ headers : list [tuple [bytes , bytes ]], path_is_ignored : bool
175+ ) -> None :
158176 exclude_header = "exclude-logging"
159177 scope = {
160178 "headers" : headers ,
161179 }
162180
163181 # pylint: disable=W0212:protected-access
164- actual = FilteredAccessLoggerMiddleware ._is_excluded_via_header (scope , exclude_header ) # type: ignore
182+ actual = FilteredAccessLoggerMiddleware ._is_excluded_via_header (
183+ scope , exclude_header
184+ ) # type: ignore
165185
166186 assert actual == path_is_ignored
167187
168188
169- @pytest .mark .parametrize ("headers,path_is_ignored" , [([(b"Exclude-Logging" , b"" )], False ), ([], False )])
189+ @pytest .mark .parametrize (
190+ "headers,path_is_ignored" , [([(b"Exclude-Logging" , b"" )], False ), ([], False )]
191+ )
170192def test_not_configured_exclude_header_does_not_cause_any_logs_to_be_excluded (
171193 headers : list [tuple [bytes , bytes ]], path_is_ignored : bool
172194) -> None :
173195 exclude_header = ""
174196 scope = {"headers" : headers }
175197
176198 # pylint: disable=W0212:protected-access
177- actual = FilteredAccessLoggerMiddleware ._is_excluded_via_header (scope , exclude_header ) # type: ignore
199+ actual = FilteredAccessLoggerMiddleware ._is_excluded_via_header (
200+ scope , exclude_header
201+ ) # type: ignore
178202
179203 assert actual == path_is_ignored
0 commit comments