Skip to content

Commit fe22fb3

Browse files
authored
Merge pull request #1274 from jspricke/fix_repr_py311
Fix repr() checks for Python 3.11
2 parents 0c15f1f + eabe727 commit fe22fb3

File tree

1 file changed

+44
-18
lines changed

1 file changed

+44
-18
lines changed

test/test_events.py

+44-18
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,18 @@ def test_remotesettingschanged_repr(self):
207207
),
208208
}
209209

210-
assert repr(e) == (
211-
"<RemoteSettingsChanged changed_settings:{ChangedSetting("
212-
"setting=SettingCodes.INITIAL_WINDOW_SIZE, original_value=65536, "
213-
"new_value=32768)}>"
214-
)
210+
if sys.version_info >= (3, 11):
211+
assert repr(e) == (
212+
"<RemoteSettingsChanged changed_settings:{ChangedSetting("
213+
"setting=4, original_value=65536, "
214+
"new_value=32768)}>"
215+
)
216+
else:
217+
assert repr(e) == (
218+
"<RemoteSettingsChanged changed_settings:{ChangedSetting("
219+
"setting=SettingCodes.INITIAL_WINDOW_SIZE, original_value=65536, "
220+
"new_value=32768)}>"
221+
)
215222

216223
def test_pingreceived_repr(self):
217224
"""
@@ -249,10 +256,16 @@ def test_streamreset_repr(self):
249256
e.error_code = h2.errors.ErrorCodes.ENHANCE_YOUR_CALM
250257
e.remote_reset = False
251258

252-
assert repr(e) == (
253-
"<StreamReset stream_id:919, "
254-
"error_code:ErrorCodes.ENHANCE_YOUR_CALM, remote_reset:False>"
255-
)
259+
if sys.version_info >= (3, 11):
260+
assert repr(e) == (
261+
"<StreamReset stream_id:919, "
262+
"error_code:11, remote_reset:False>"
263+
)
264+
else:
265+
assert repr(e) == (
266+
"<StreamReset stream_id:919, "
267+
"error_code:ErrorCodes.ENHANCE_YOUR_CALM, remote_reset:False>"
268+
)
256269

257270
def test_pushedstreamreceived_repr(self):
258271
"""
@@ -284,11 +297,18 @@ def test_settingsacknowledged_repr(self):
284297
),
285298
}
286299

287-
assert repr(e) == (
288-
"<SettingsAcknowledged changed_settings:{ChangedSetting("
289-
"setting=SettingCodes.INITIAL_WINDOW_SIZE, original_value=65536, "
290-
"new_value=32768)}>"
291-
)
300+
if sys.version_info >= (3, 11):
301+
assert repr(e) == (
302+
"<SettingsAcknowledged changed_settings:{ChangedSetting("
303+
"setting=4, original_value=65536, "
304+
"new_value=32768)}>"
305+
)
306+
else:
307+
assert repr(e) == (
308+
"<SettingsAcknowledged changed_settings:{ChangedSetting("
309+
"setting=SettingCodes.INITIAL_WINDOW_SIZE, original_value=65536, "
310+
"new_value=32768)}>"
311+
)
292312

293313
def test_priorityupdated_repr(self):
294314
"""
@@ -318,10 +338,16 @@ def test_connectionterminated_repr(self, additional_data, data_repr):
318338
e.last_stream_id = 33
319339
e.additional_data = additional_data
320340

321-
assert repr(e) == (
322-
"<ConnectionTerminated error_code:ErrorCodes.INADEQUATE_SECURITY, "
323-
"last_stream_id:33, additional_data:%s>" % data_repr
324-
)
341+
if sys.version_info >= (3, 11):
342+
assert repr(e) == (
343+
"<ConnectionTerminated error_code:12, "
344+
"last_stream_id:33, additional_data:%s>" % data_repr
345+
)
346+
else:
347+
assert repr(e) == (
348+
"<ConnectionTerminated error_code:ErrorCodes.INADEQUATE_SECURITY, "
349+
"last_stream_id:33, additional_data:%s>" % data_repr
350+
)
325351

326352
def test_alternativeserviceavailable_repr(self):
327353
"""

0 commit comments

Comments
 (0)