Skip to content

Commit

Permalink
Merge pull request python-hyper#1274 from jspricke/fix_repr_py311
Browse files Browse the repository at this point in the history
Fix repr() checks for Python 3.11
  • Loading branch information
mhils authored Jan 30, 2023
2 parents 0c15f1f + eabe727 commit fe22fb3
Showing 1 changed file with 44 additions and 18 deletions.
62 changes: 44 additions & 18 deletions test/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,18 @@ def test_remotesettingschanged_repr(self):
),
}

assert repr(e) == (
"<RemoteSettingsChanged changed_settings:{ChangedSetting("
"setting=SettingCodes.INITIAL_WINDOW_SIZE, original_value=65536, "
"new_value=32768)}>"
)
if sys.version_info >= (3, 11):
assert repr(e) == (
"<RemoteSettingsChanged changed_settings:{ChangedSetting("
"setting=4, original_value=65536, "
"new_value=32768)}>"
)
else:
assert repr(e) == (
"<RemoteSettingsChanged changed_settings:{ChangedSetting("
"setting=SettingCodes.INITIAL_WINDOW_SIZE, original_value=65536, "
"new_value=32768)}>"
)

def test_pingreceived_repr(self):
"""
Expand Down Expand Up @@ -249,10 +256,16 @@ def test_streamreset_repr(self):
e.error_code = h2.errors.ErrorCodes.ENHANCE_YOUR_CALM
e.remote_reset = False

assert repr(e) == (
"<StreamReset stream_id:919, "
"error_code:ErrorCodes.ENHANCE_YOUR_CALM, remote_reset:False>"
)
if sys.version_info >= (3, 11):
assert repr(e) == (
"<StreamReset stream_id:919, "
"error_code:11, remote_reset:False>"
)
else:
assert repr(e) == (
"<StreamReset stream_id:919, "
"error_code:ErrorCodes.ENHANCE_YOUR_CALM, remote_reset:False>"
)

def test_pushedstreamreceived_repr(self):
"""
Expand Down Expand Up @@ -284,11 +297,18 @@ def test_settingsacknowledged_repr(self):
),
}

assert repr(e) == (
"<SettingsAcknowledged changed_settings:{ChangedSetting("
"setting=SettingCodes.INITIAL_WINDOW_SIZE, original_value=65536, "
"new_value=32768)}>"
)
if sys.version_info >= (3, 11):
assert repr(e) == (
"<SettingsAcknowledged changed_settings:{ChangedSetting("
"setting=4, original_value=65536, "
"new_value=32768)}>"
)
else:
assert repr(e) == (
"<SettingsAcknowledged changed_settings:{ChangedSetting("
"setting=SettingCodes.INITIAL_WINDOW_SIZE, original_value=65536, "
"new_value=32768)}>"
)

def test_priorityupdated_repr(self):
"""
Expand Down Expand Up @@ -318,10 +338,16 @@ def test_connectionterminated_repr(self, additional_data, data_repr):
e.last_stream_id = 33
e.additional_data = additional_data

assert repr(e) == (
"<ConnectionTerminated error_code:ErrorCodes.INADEQUATE_SECURITY, "
"last_stream_id:33, additional_data:%s>" % data_repr
)
if sys.version_info >= (3, 11):
assert repr(e) == (
"<ConnectionTerminated error_code:12, "
"last_stream_id:33, additional_data:%s>" % data_repr
)
else:
assert repr(e) == (
"<ConnectionTerminated error_code:ErrorCodes.INADEQUATE_SECURITY, "
"last_stream_id:33, additional_data:%s>" % data_repr
)

def test_alternativeserviceavailable_repr(self):
"""
Expand Down

0 comments on commit fe22fb3

Please sign in to comment.