2020from hyper .common .headers import HTTPHeaderMap
2121from hyper .compat import zlib_compressobj
2222from hyper .contrib import HTTP20Adapter
23- from hyper .http20 .error_code_registry import H2_ERROR_CODE_REGISTRY
23+ import hyper .http20 .errors as errors
2424import errno
2525import os
2626import pytest
@@ -1199,9 +1199,11 @@ def test_goaway_frame_PROTOCOL_ERROR(self):
11991199 c .receive_frame (f )
12001200
12011201 err_msg = str (conn_err )
1202- assert H2_ERROR_CODE_REGISTRY [f .error_code ]['Name' ] in err_msg
1203- assert H2_ERROR_CODE_REGISTRY [f .error_code ]['Description' ] in err_msg
1204- assert hex (f .error_code ) in err_msg
1202+ name , number , description = errors .get_data (1 )
1203+
1204+ assert name in err_msg
1205+ assert number in err_msg
1206+ assert description in err_msg
12051207
12061208 def test_goaway_frame_HTTP_1_1_REQUIRED (self ):
12071209 f = GoAwayFrame (0 )
@@ -1218,9 +1220,11 @@ def test_goaway_frame_HTTP_1_1_REQUIRED(self):
12181220 c .receive_frame (f )
12191221
12201222 err_msg = str (conn_err )
1221- assert H2_ERROR_CODE_REGISTRY [f .error_code ]['Name' ] in err_msg
1222- assert H2_ERROR_CODE_REGISTRY [f .error_code ]['Description' ] in err_msg
1223- assert hex (f .error_code ) in err_msg
1223+ name , number , description = errors .get_data (13 )
1224+
1225+ assert name in err_msg
1226+ assert number in err_msg
1227+ assert description in err_msg
12241228
12251229 def test_goaway_frame_NO_ERROR (self ):
12261230 f = GoAwayFrame (0 )
@@ -1235,27 +1239,6 @@ def test_goaway_frame_NO_ERROR(self):
12351239 # dealing with a standard and graceful shutdown.
12361240 c .receive_frame (f )
12371241
1238- def test_goaway_frame_additional_data (self ):
1239- f = GoAwayFrame (0 )
1240- # Set error code to SETTINGS_TIMEOUT
1241- f .error_code = 4 ;
1242- f .additional_data = 'special additional data' ;
1243-
1244- c = HTTP20Connection ('www.google.com' )
1245- c ._sock = DummySocket ()
1246-
1247- # 'Receive' the GOAWAY frame.
1248- # The connection error contains the extra data if it's available and
1249- # the description from the spec if it's not available. This test
1250- # validates that the additional data replaces the standard description.
1251- with pytest .raises (ConnectionError ) as conn_err :
1252- c .receive_frame (f )
1253-
1254- err_msg = str (conn_err )
1255- assert H2_ERROR_CODE_REGISTRY [f .error_code ]['Name' ] in err_msg
1256- assert 'special additional data' in err_msg
1257- assert hex (f .error_code ) in err_msg
1258-
12591242 def test_goaway_frame_invalid_error_code (self ):
12601243 f = GoAwayFrame (0 )
12611244 # Set error code to non existing error
@@ -1272,8 +1255,11 @@ def test_goaway_frame_invalid_error_code(self):
12721255 c .receive_frame (f )
12731256
12741257 err_msg = str (conn_err )
1258+ with pytest .raises (ValueError ):
1259+ name , number , description = errors .get_data (100 )
1260+
12751261 assert 'data about non existing error code' in err_msg
1276- assert hex (f .error_code ) in err_msg
1262+ assert str (f .error_code ) in err_msg
12771263
12781264# Some utility classes for the tests.
12791265class NullEncoder (object ):
0 commit comments