@@ -221,6 +221,34 @@ def test_sort_cmp_arg(self):
221221 w .reset ()
222222 self .assertWarning (sorted (lst , cmp ), w , expected )
223223
224+ def test_next_method (self ):
225+ expected = 'iterator.next() is not supported in 3.x; use __next__() instead'
226+ it = iter (range (5 ))
227+ with check_py3k_warnings () as w :
228+ self .assertWarning (it .next (), w , expected )
229+
230+ def test_intern (self ):
231+ expected = 'intern() is not supported in 3.x: use sys.intern() instead'
232+ with check_py3k_warnings () as w :
233+ self .assertWarning (intern ('pygrate-next-method' ), w , expected )
234+
235+ def test_range_materialization (self ):
236+ expected = 'range() may require list materialization in 3.x'
237+ with check_py3k_warnings () as w :
238+ self .assertWarning (range (5 ) + [5 ], w , expected )
239+
240+ def test_xrange_materialization (self ):
241+ expected = 'xrange() may require list materialization in 3.x'
242+ with check_py3k_warnings () as w :
243+ items = xrange (5 )
244+ self .assertWarning (None , w , expected )
245+
246+ def test_dict_listlike_materialization (self ):
247+ expected = 'dict.keys() may require list materialization in 3.x'
248+ d = {'a' : 1 , 'b' : 2 }
249+ with check_py3k_warnings () as w :
250+ self .assertWarning (d .keys ()[0 ], w , expected )
251+
224252 def test_sys_exc_clear (self ):
225253 expected = 'sys.exc_clear() not supported in 3.x; use except clauses'
226254 with check_py3k_warnings () as w :
@@ -288,9 +316,10 @@ def test_bytesio_truncate(self):
288316 from io import BytesIO
289317 x = BytesIO (b'AAAAAA' )
290318 expected = "BytesIO.truncate() does not shift the file pointer: use seek(0) before doing truncate(0)"
291- self .assertWarning (x .truncate (0 ), w , expected )
292- w .reset ()
293- self .assertNoWarning (x .truncate (- 1 ), w )
319+ with check_py3k_warnings () as w :
320+ self .assertWarning (x .truncate (0 ), w , expected )
321+ w .reset ()
322+ self .assertNoWarning (x .truncate (- 1 ), w )
294323
295324 def test_file_open (self ):
296325 expected = ("The builtin 'file()'/'open()' function is not supported in 3.x, "
0 commit comments