20
20
from hyper .common .headers import HTTPHeaderMap
21
21
from hyper .compat import zlib_compressobj
22
22
from hyper .contrib import HTTP20Adapter
23
- from hyper .http20 .error_code_registry import H2_ERROR_CODE_REGISTRY
23
+ import hyper .http20 .errors as errors
24
24
import errno
25
25
import os
26
26
import pytest
@@ -1199,9 +1199,11 @@ def test_goaway_frame_PROTOCOL_ERROR(self):
1199
1199
c .receive_frame (f )
1200
1200
1201
1201
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
1205
1207
1206
1208
def test_goaway_frame_HTTP_1_1_REQUIRED (self ):
1207
1209
f = GoAwayFrame (0 )
@@ -1218,9 +1220,11 @@ def test_goaway_frame_HTTP_1_1_REQUIRED(self):
1218
1220
c .receive_frame (f )
1219
1221
1220
1222
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
1224
1228
1225
1229
def test_goaway_frame_NO_ERROR (self ):
1226
1230
f = GoAwayFrame (0 )
@@ -1235,27 +1239,6 @@ def test_goaway_frame_NO_ERROR(self):
1235
1239
# dealing with a standard and graceful shutdown.
1236
1240
c .receive_frame (f )
1237
1241
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
-
1259
1242
def test_goaway_frame_invalid_error_code (self ):
1260
1243
f = GoAwayFrame (0 )
1261
1244
# Set error code to non existing error
@@ -1272,8 +1255,11 @@ def test_goaway_frame_invalid_error_code(self):
1272
1255
c .receive_frame (f )
1273
1256
1274
1257
err_msg = str (conn_err )
1258
+ with pytest .raises (ValueError ):
1259
+ name , number , description = errors .get_data (100 )
1260
+
1275
1261
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
1277
1263
1278
1264
# Some utility classes for the tests.
1279
1265
class NullEncoder (object ):
0 commit comments