Changeset 391 for python/trunk/Lib/test/test_coercion.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/test/test_coercion.py
r2 r391 1 1 import copy 2 import warnings3 2 import unittest 4 from test.test_support import run_unittest, TestFailed 3 from test.test_support import run_unittest, TestFailed, check_warnings 4 5 5 6 6 # Fake a number that implements numeric methods through __coerce__ … … 224 224 225 225 226 227 process_infix_results() 228 # now infix_results has two lists of results for every pairing. 226 with check_warnings(("classic (int|long) division", DeprecationWarning), 227 quiet=True): 228 process_infix_results() 229 # now infix_results has two lists of results for every pairing. 229 230 230 231 prefix_binops = [ 'divmod' ] … … 266 267 'a %s b' % op, {'a': a, 'b': b}) 267 268 else: 268 self.assertEqual s(format_result(res),269 270 269 self.assertEqual(format_result(res), 270 format_result(eval('a %s b' % op)), 271 '%s %s %s == %s failed' % (a, op, b, res)) 271 272 try: 272 273 z = copy.copy(a) … … 282 283 else: 283 284 exec('z %s= b' % op) 284 self.assertEqual s(ires, z)285 self.assertEqual(ires, z) 285 286 286 287 def test_prefix_binops(self): … … 293 294 '%s(a, b)' % op, {'a': a, 'b': b}) 294 295 else: 295 self.assertEqual s(format_result(res),296 297 296 self.assertEqual(format_result(res), 297 format_result(eval('%s(a, b)' % op)), 298 '%s(%s, %s) == %s failed' % (op, a, b, res)) 298 299 299 300 def test_cmptypes(self): … … 303 304 evil_coercer = CoerceTo(42) 304 305 # Make sure these don't crash any more 305 self.assertNotEqual s(cmp(u'fish', evil_coercer), 0)306 self.assertNotEqual s(cmp(slice(1), evil_coercer), 0)306 self.assertNotEqual(cmp(u'fish', evil_coercer), 0) 307 self.assertNotEqual(cmp(slice(1), evil_coercer), 0) 307 308 # ...but that this still works 308 309 class WackyComparer(object): 309 310 def __cmp__(slf, other): 310 self.assert _(other == 42, 'expected evil_coercer, got %r' % other)311 self.assertTrue(other == 42, 'expected evil_coercer, got %r' % other) 311 312 return 0 312 313 __hash__ = None # Invalid cmp makes this unhashable 313 self.assertEqual s(cmp(WackyComparer(), evil_coercer), 0)314 self.assertEqual(cmp(WackyComparer(), evil_coercer), 0) 314 315 # ...and classic classes too, since that code path is a little different 315 316 class ClassicWackyComparer: 316 317 def __cmp__(slf, other): 317 self.assert _(other == 42, 'expected evil_coercer, got %r' % other)318 self.assertTrue(other == 42, 'expected evil_coercer, got %r' % other) 318 319 return 0 319 self.assertEqual s(cmp(ClassicWackyComparer(), evil_coercer), 0)320 self.assertEqual(cmp(ClassicWackyComparer(), evil_coercer), 0) 320 321 321 322 def test_infinite_rec_classic_classes(self): … … 338 339 339 340 def test_main(): 340 w arnings.filterwarnings("ignore",341 r'complex divmod\(\), // and % are deprecated',342 DeprecationWarning,343 r'test.test_coercion$')344 run_unittest(CoercionTest)341 with check_warnings(("complex divmod.., // and % are deprecated", 342 DeprecationWarning), 343 ("classic (int|long) division", DeprecationWarning), 344 quiet=True): 345 run_unittest(CoercionTest) 345 346 346 347 if __name__ == "__main__":
Note:
See TracChangeset
for help on using the changeset viewer.