11from unittest import mock
22from test import support
33from test .support import socket_helper
4- from test .support import warnings_helper
54from test .test_httpservers import NoLogRequestHandler
65from unittest import TestCase
76from wsgiref .util import setup_testing_defaults
@@ -81,41 +80,26 @@ def run_amock(app=hello_app, data=b"GET / HTTP/1.0\n\n"):
8180
8281 return out .getvalue (), err .getvalue ()
8382
84- def compare_generic_iter (make_it ,match ):
85- """Utility to compare a generic 2.1/2.2+ iterator with an iterable
8683
87- If running under Python 2.2+, this tests the iterator using iter()/next(),
88- as well as __getitem__. 'make_it' must be a function returning a fresh
84+ def compare_generic_iter (make_it , match ):
85+ """Utility to compare a generic iterator with an iterable
86+
87+ This tests the iterator using iter()/next().
88+ 'make_it' must be a function returning a fresh
8989 iterator to be tested (since this may test the iterator twice)."""
9090
9191 it = make_it ()
92- n = 0
92+ if not iter (it ) is it :
93+ raise AssertionError
9394 for item in match :
94- if not it [ n ] == item : raise AssertionError
95- n += 1
95+ if not next ( it ) == item :
96+ raise AssertionError
9697 try :
97- it [ n ]
98- except IndexError :
98+ next ( it )
99+ except StopIteration :
99100 pass
100101 else :
101- raise AssertionError ("Too many items from __getitem__" ,it )
102-
103- try :
104- iter , StopIteration
105- except NameError :
106- pass
107- else :
108- # Only test iter mode under 2.2+
109- it = make_it ()
110- if not iter (it ) is it : raise AssertionError
111- for item in match :
112- if not next (it ) == item : raise AssertionError
113- try :
114- next (it )
115- except StopIteration :
116- pass
117- else :
118- raise AssertionError ("Too many items from .__next__()" , it )
102+ raise AssertionError ("Too many items from .__next__()" , it )
119103
120104
121105class IntegrationTests (TestCase ):
@@ -340,7 +324,6 @@ def checkReqURI(self,uri,query=1,**kw):
340324 util .setup_testing_defaults (kw )
341325 self .assertEqual (util .request_uri (kw ,query ),uri )
342326
343- @warnings_helper .ignore_warnings (category = DeprecationWarning )
344327 def checkFW (self ,text ,size ,match ):
345328
346329 def make_it (text = text ,size = size ):
@@ -359,13 +342,6 @@ def make_it(text=text,size=size):
359342 it .close ()
360343 self .assertTrue (it .filelike .closed )
361344
362- def test_filewrapper_getitem_deprecation (self ):
363- wrapper = util .FileWrapper (StringIO ('foobar' ), 3 )
364- with self .assertWarnsRegex (DeprecationWarning ,
365- r'Use iterator protocol instead' ):
366- # This should have returned 'bar'.
367- self .assertEqual (wrapper [1 ], 'foo' )
368-
369345 def testSimpleShifts (self ):
370346 self .checkShift ('' ,'/' , '' , '/' , '' )
371347 self .checkShift ('' ,'/x' , 'x' , '/x' , '' )
0 commit comments