mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	gh-71339: Use new assertion methods in tests (GH-129046)
This commit is contained in:
		
							parent
							
								
									bb244fd33d
								
							
						
					
					
						commit
						2602d8ae98
					
				
					 117 changed files with 407 additions and 445 deletions
				
			
		|  | @ -357,7 +357,7 @@ def test_capi1(): | |||
|             except TypeError as err: | ||||
|                 co = err.__traceback__.tb_frame.f_code | ||||
|                 self.assertEqual(co.co_name, "test_capi1") | ||||
|                 self.assertTrue(co.co_filename.endswith('test_exceptions.py')) | ||||
|                 self.assertEndsWith(co.co_filename, 'test_exceptions.py') | ||||
|             else: | ||||
|                 self.fail("Expected exception") | ||||
| 
 | ||||
|  | @ -369,7 +369,7 @@ def test_capi2(): | |||
|                 tb = err.__traceback__.tb_next | ||||
|                 co = tb.tb_frame.f_code | ||||
|                 self.assertEqual(co.co_name, "__init__") | ||||
|                 self.assertTrue(co.co_filename.endswith('test_exceptions.py')) | ||||
|                 self.assertEndsWith(co.co_filename, 'test_exceptions.py') | ||||
|                 co2 = tb.tb_frame.f_back.f_code | ||||
|                 self.assertEqual(co2.co_name, "test_capi2") | ||||
|             else: | ||||
|  | @ -598,7 +598,7 @@ def test_invalid_setstate(self): | |||
|     def test_notes(self): | ||||
|         for e in [BaseException(1), Exception(2), ValueError(3)]: | ||||
|             with self.subTest(e=e): | ||||
|                 self.assertFalse(hasattr(e, '__notes__')) | ||||
|                 self.assertNotHasAttr(e, '__notes__') | ||||
|                 e.add_note("My Note") | ||||
|                 self.assertEqual(e.__notes__, ["My Note"]) | ||||
| 
 | ||||
|  | @ -610,7 +610,7 @@ def test_notes(self): | |||
|                 self.assertEqual(e.__notes__, ["My Note", "Your Note"]) | ||||
| 
 | ||||
|                 del e.__notes__ | ||||
|                 self.assertFalse(hasattr(e, '__notes__')) | ||||
|                 self.assertNotHasAttr(e, '__notes__') | ||||
| 
 | ||||
|                 e.add_note("Our Note") | ||||
|                 self.assertEqual(e.__notes__, ["Our Note"]) | ||||
|  | @ -1627,7 +1627,7 @@ def test_exception_with_doc(self): | |||
|         # test basic usage of PyErr_NewException | ||||
|         error1 = _testcapi.make_exception_with_doc("_testcapi.error1") | ||||
|         self.assertIs(type(error1), type) | ||||
|         self.assertTrue(issubclass(error1, Exception)) | ||||
|         self.assertIsSubclass(error1, Exception) | ||||
|         self.assertIsNone(error1.__doc__) | ||||
| 
 | ||||
|         # test with given docstring | ||||
|  | @ -1637,21 +1637,21 @@ def test_exception_with_doc(self): | |||
|         # test with explicit base (without docstring) | ||||
|         error3 = _testcapi.make_exception_with_doc("_testcapi.error3", | ||||
|                                                    base=error2) | ||||
|         self.assertTrue(issubclass(error3, error2)) | ||||
|         self.assertIsSubclass(error3, error2) | ||||
| 
 | ||||
|         # test with explicit base tuple | ||||
|         class C(object): | ||||
|             pass | ||||
|         error4 = _testcapi.make_exception_with_doc("_testcapi.error4", doc4, | ||||
|                                                    (error3, C)) | ||||
|         self.assertTrue(issubclass(error4, error3)) | ||||
|         self.assertTrue(issubclass(error4, C)) | ||||
|         self.assertIsSubclass(error4, error3) | ||||
|         self.assertIsSubclass(error4, C) | ||||
|         self.assertEqual(error4.__doc__, doc4) | ||||
| 
 | ||||
|         # test with explicit dictionary | ||||
|         error5 = _testcapi.make_exception_with_doc("_testcapi.error5", "", | ||||
|                                                    error4, {'a': 1}) | ||||
|         self.assertTrue(issubclass(error5, error4)) | ||||
|         self.assertIsSubclass(error5, error4) | ||||
|         self.assertEqual(error5.a, 1) | ||||
|         self.assertEqual(error5.__doc__, "") | ||||
| 
 | ||||
|  | @ -1744,7 +1744,7 @@ def test_unhandled(self): | |||
|                     self.assertIn("<exception str() failed>", report) | ||||
|                 else: | ||||
|                     self.assertIn("test message", report) | ||||
|                 self.assertTrue(report.endswith("\n")) | ||||
|                 self.assertEndsWith(report, "\n") | ||||
| 
 | ||||
|     @cpython_only | ||||
|     # Python built with Py_TRACE_REFS fail with a fatal error in | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka