@@ -42,7 +42,8 @@ def __init__(self, request: HTTPRequest, spec: Spec):
42
42
self .request = request
43
43
self .spec = spec
44
44
if request .url is None :
45
- raise RuntimeError ("Request URL is missing" )
45
+ msg = "Request URL is missing"
46
+ raise RuntimeError (msg )
46
47
self ._url_parsed = urlparse (request .url )
47
48
48
49
cookie : SimpleCookie = SimpleCookie ()
@@ -90,7 +91,8 @@ def path(self) -> str:
90
91
url = u [: len (path )] + r"foo"
91
92
92
93
if url is None :
93
- raise ValueError (f"Could not find matching pattern for { o .path } " )
94
+ msg = f"Could not find matching pattern for { o .path } "
95
+ raise ValueError (msg )
94
96
return url
95
97
96
98
@property
@@ -103,7 +105,8 @@ def body(self) -> Optional[str]:
103
105
if self .request .body is None :
104
106
return None
105
107
if not isinstance (self .request .body , bytes ):
106
- raise AssertionError ('Request body is invalid' )
108
+ msg = 'Request body is invalid'
109
+ raise AssertionError (msg )
107
110
return self .request .body .decode ("utf-8" )
108
111
109
112
@property
@@ -128,7 +131,8 @@ def __init__(self, response: HTTPResponse):
128
131
@property
129
132
def data (self ) -> str :
130
133
if not isinstance (self .response .body , bytes ):
131
- raise AssertionError ('Response body is invalid' )
134
+ msg = 'Response body is invalid'
135
+ raise AssertionError (msg )
132
136
return self .response .body .decode ("utf-8" )
133
137
134
138
@property
@@ -165,21 +169,23 @@ def validate_request(response):
165
169
166
170
def maybe_patch_ioloop ():
167
171
"""a windows 3.8+ patch for the asyncio loop"""
168
- if sys .platform .startswith ("win" ) and tornado .version_info < (6 , 1 ):
169
- if sys .version_info >= (3 , 8 ):
170
-
171
- try :
172
- from asyncio import WindowsProactorEventLoopPolicy , WindowsSelectorEventLoopPolicy
173
- except ImportError :
174
- pass
175
- # not affected
176
- else :
177
- from asyncio import get_event_loop_policy , set_event_loop_policy
178
-
179
- if type (get_event_loop_policy ()) is WindowsProactorEventLoopPolicy :
180
- # WindowsProactorEventLoopPolicy is not compatible with tornado 6
181
- # fallback to the pre-3.8 default of Selector
182
- set_event_loop_policy (WindowsSelectorEventLoopPolicy ())
172
+ if (
173
+ sys .platform .startswith ("win" )
174
+ and tornado .version_info < (6 , 1 )
175
+ and sys .version_info >= (3 , 8 )
176
+ ):
177
+ try :
178
+ from asyncio import WindowsProactorEventLoopPolicy , WindowsSelectorEventLoopPolicy
179
+ except ImportError :
180
+ pass
181
+ # not affected
182
+ else :
183
+ from asyncio import get_event_loop_policy , set_event_loop_policy
184
+
185
+ if type (get_event_loop_policy ()) is WindowsProactorEventLoopPolicy :
186
+ # WindowsProactorEventLoopPolicy is not compatible with tornado 6
187
+ # fallback to the pre-3.8 default of Selector
188
+ set_event_loop_policy (WindowsSelectorEventLoopPolicy ())
183
189
184
190
185
191
def expected_http_error (error , expected_code , expected_message = None ):
0 commit comments