mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Convert test_stringprep to use unittest.
This commit is contained in:
		
							parent
							
								
									615b49b097
								
							
						
					
					
						commit
						1dd9a2ccc3
					
				
					 1 changed files with 69 additions and 61 deletions
				
			
		|  | @ -1,71 +1,73 @@ | ||||||
| # To fully test this module, we would need a copy of the stringprep tables. | # To fully test this module, we would need a copy of the stringprep tables. | ||||||
| # Since we don't have them, this test checks only a few codepoints. | # Since we don't have them, this test checks only a few codepoints. | ||||||
| 
 | 
 | ||||||
| from test.test_support import verify, vereq | import unittest | ||||||
|  | from test import test_support | ||||||
| 
 | 
 | ||||||
| import stringprep |  | ||||||
| from stringprep import * | from stringprep import * | ||||||
| 
 | 
 | ||||||
| verify(in_table_a1(u"\u0221")) | class StringprepTests(unittest.TestCase): | ||||||
| verify(not in_table_a1(u"\u0222")) |     def test(self): | ||||||
|  |         self.failUnless(in_table_a1(u"\u0221")) | ||||||
|  |         self.failIf(in_table_a1(u"\u0222")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_b1(u"\u00ad")) |         self.failUnless(in_table_b1(u"\u00ad")) | ||||||
| verify(not in_table_b1(u"\u00ae")) |         self.failIf(in_table_b1(u"\u00ae")) | ||||||
| 
 | 
 | ||||||
| verify(map_table_b2(u"\u0041"), u"\u0061") |         self.failUnless(map_table_b2(u"\u0041"), u"\u0061") | ||||||
| verify(map_table_b2(u"\u0061"), u"\u0061") |         self.failUnless(map_table_b2(u"\u0061"), u"\u0061") | ||||||
| 
 | 
 | ||||||
| verify(map_table_b3(u"\u0041"), u"\u0061") |         self.failUnless(map_table_b3(u"\u0041"), u"\u0061") | ||||||
| verify(map_table_b3(u"\u0061"), u"\u0061") |         self.failUnless(map_table_b3(u"\u0061"), u"\u0061") | ||||||
| 
 | 
 | ||||||
| verify(in_table_c11(u"\u0020")) |         self.failUnless(in_table_c11(u"\u0020")) | ||||||
| verify(not in_table_c11(u"\u0021")) |         self.failIf(in_table_c11(u"\u0021")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_c12(u"\u00a0")) |         self.failUnless(in_table_c12(u"\u00a0")) | ||||||
| verify(not in_table_c12(u"\u00a1")) |         self.failIf(in_table_c12(u"\u00a1")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_c12(u"\u00a0")) |         self.failUnless(in_table_c12(u"\u00a0")) | ||||||
| verify(not in_table_c12(u"\u00a1")) |         self.failIf(in_table_c12(u"\u00a1")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_c11_c12(u"\u00a0")) |         self.failUnless(in_table_c11_c12(u"\u00a0")) | ||||||
| verify(not in_table_c11_c12(u"\u00a1")) |         self.failIf(in_table_c11_c12(u"\u00a1")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_c21(u"\u001f")) |         self.failUnless(in_table_c21(u"\u001f")) | ||||||
| verify(not in_table_c21(u"\u0020")) |         self.failIf(in_table_c21(u"\u0020")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_c22(u"\u009f")) |         self.failUnless(in_table_c22(u"\u009f")) | ||||||
| verify(not in_table_c22(u"\u00a0")) |         self.failIf(in_table_c22(u"\u00a0")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_c21_c22(u"\u009f")) |         self.failUnless(in_table_c21_c22(u"\u009f")) | ||||||
| verify(not in_table_c21_c22(u"\u00a0")) |         self.failIf(in_table_c21_c22(u"\u00a0")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_c3(u"\ue000")) |         self.failUnless(in_table_c3(u"\ue000")) | ||||||
| verify(not in_table_c3(u"\uf900")) |         self.failIf(in_table_c3(u"\uf900")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_c4(u"\uffff")) |         self.failUnless(in_table_c4(u"\uffff")) | ||||||
| verify(not in_table_c4(u"\u0000")) |         self.failIf(in_table_c4(u"\u0000")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_c5(u"\ud800")) |         self.failUnless(in_table_c5(u"\ud800")) | ||||||
| verify(not in_table_c5(u"\ud7ff")) |         self.failIf(in_table_c5(u"\ud7ff")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_c6(u"\ufff9")) |         self.failUnless(in_table_c6(u"\ufff9")) | ||||||
| verify(not in_table_c6(u"\ufffe")) |         self.failIf(in_table_c6(u"\ufffe")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_c7(u"\u2ff0")) |         self.failUnless(in_table_c7(u"\u2ff0")) | ||||||
| verify(not in_table_c7(u"\u2ffc")) |         self.failIf(in_table_c7(u"\u2ffc")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_c8(u"\u0340")) |         self.failUnless(in_table_c8(u"\u0340")) | ||||||
| verify(not in_table_c8(u"\u0342")) |         self.failIf(in_table_c8(u"\u0342")) | ||||||
| 
 | 
 | ||||||
|         # C.9 is not in the bmp |         # C.9 is not in the bmp | ||||||
| # verify(in_table_c9(u"\U000E0001")) |         # self.failUnless(in_table_c9(u"\U000E0001")) | ||||||
| # verify(not in_table_c8(u"\U000E0002")) |         # self.failIf(in_table_c8(u"\U000E0002")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_d1(u"\u05be")) |         self.failUnless(in_table_d1(u"\u05be")) | ||||||
| verify(not in_table_d1(u"\u05bf")) |         self.failIf(in_table_d1(u"\u05bf")) | ||||||
| 
 | 
 | ||||||
| verify(in_table_d2(u"\u0041")) |         self.failUnless(in_table_d2(u"\u0041")) | ||||||
| verify(not in_table_d2(u"\u0040")) |         self.failIf(in_table_d2(u"\u0040")) | ||||||
| 
 | 
 | ||||||
|         # This would generate a hash of all predicates. However, running |         # This would generate a hash of all predicates. However, running | ||||||
|         # it is quite expensive, and only serves to detect changes in the |         # it is quite expensive, and only serves to detect changes in the | ||||||
|  | @ -86,3 +88,9 @@ | ||||||
|         #     h = hashlib.sha1() |         #     h = hashlib.sha1() | ||||||
|         #     h.update(data) |         #     h.update(data) | ||||||
|         #     print p, h.hexdigest() |         #     print p, h.hexdigest() | ||||||
|  | 
 | ||||||
|  | def test_main(): | ||||||
|  |     test_support.run_unittest(StringprepTests) | ||||||
|  |      | ||||||
|  | if __name__ == '__main__': | ||||||
|  |     test_main() | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Collin Winter
						Collin Winter