Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_stringprep.py @ 39042:c02fa187e0f4 legacy-trunk
Part of SF patch #1484695. This removes dead code. The chksum was
already verified in .frombuf() on the lines above. If there was
a problem an exception is raised, so there was no way this condition
could have been true.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Mon, 10 Jul 2006 00:23:17 +0000 |
| parents | 32a187f3d5ba |
| children | 3b1396b01239 06145fbc7ab9 |
| rev | line source |
|---|---|
| 28692 | 1 # To fully test this module, we would need a copy of the stringprep tables. |
| 2 # Since we don't have them, this test checks only a few codepoints. | |
| 3 | |
| 4 from test.test_support import verify, vereq | |
| 5 | |
| 6 import stringprep | |
| 7 from stringprep import * | |
| 8 | |
| 9 verify(in_table_a1(u"\u0221")) | |
| 10 verify(not in_table_a1(u"\u0222")) | |
| 11 | |
| 12 verify(in_table_b1(u"\u00ad")) | |
| 13 verify(not in_table_b1(u"\u00ae")) | |
| 14 | |
| 15 verify(map_table_b2(u"\u0041"), u"\u0061") | |
| 16 verify(map_table_b2(u"\u0061"), u"\u0061") | |
| 17 | |
| 18 verify(map_table_b3(u"\u0041"), u"\u0061") | |
| 19 verify(map_table_b3(u"\u0061"), u"\u0061") | |
| 20 | |
| 21 verify(in_table_c11(u"\u0020")) | |
| 22 verify(not in_table_c11(u"\u0021")) | |
| 23 | |
| 24 verify(in_table_c12(u"\u00a0")) | |
| 25 verify(not in_table_c12(u"\u00a1")) | |
| 26 | |
| 27 verify(in_table_c12(u"\u00a0")) | |
| 28 verify(not in_table_c12(u"\u00a1")) | |
| 29 | |
| 30 verify(in_table_c11_c12(u"\u00a0")) | |
| 31 verify(not in_table_c11_c12(u"\u00a1")) | |
| 32 | |
| 33 verify(in_table_c21(u"\u001f")) | |
| 34 verify(not in_table_c21(u"\u0020")) | |
| 35 | |
| 36 verify(in_table_c22(u"\u009f")) | |
| 37 verify(not in_table_c22(u"\u00a0")) | |
| 38 | |
| 39 verify(in_table_c21_c22(u"\u009f")) | |
| 40 verify(not in_table_c21_c22(u"\u00a0")) | |
| 41 | |
| 42 verify(in_table_c3(u"\ue000")) | |
| 43 verify(not in_table_c3(u"\uf900")) | |
| 44 | |
| 45 verify(in_table_c4(u"\uffff")) | |
| 46 verify(not in_table_c4(u"\u0000")) | |
| 47 | |
| 48 verify(in_table_c5(u"\ud800")) | |
| 49 verify(not in_table_c5(u"\ud7ff")) | |
| 50 | |
| 51 verify(in_table_c6(u"\ufff9")) | |
| 52 verify(not in_table_c6(u"\ufffe")) | |
| 53 | |
| 54 verify(in_table_c7(u"\u2ff0")) | |
| 55 verify(not in_table_c7(u"\u2ffc")) | |
| 56 | |
| 57 verify(in_table_c8(u"\u0340")) | |
| 58 verify(not in_table_c8(u"\u0342")) | |
| 59 | |
| 60 # C.9 is not in the bmp | |
| 61 # verify(in_table_c9(u"\U000E0001")) | |
| 62 # verify(not in_table_c8(u"\U000E0002")) | |
| 63 | |
| 64 verify(in_table_d1(u"\u05be")) | |
| 65 verify(not in_table_d1(u"\u05bf")) | |
| 66 | |
| 67 verify(in_table_d2(u"\u0041")) | |
| 68 verify(not in_table_d2(u"\u0040")) | |
| 69 | |
| 70 # This would generate a hash of all predicates. However, running | |
| 71 # it is quite expensive, and only serves to detect changes in the | |
| 72 # unicode database. Instead, stringprep.py asserts the version of | |
| 30723 | 73 # the database. |
| 28692 | 74 |
|
38052
32a187f3d5ba
In stdlib, use hashlib instead of deprecated md5 and sha modules.
Georg Brandl <georg@python.org>
parents:
30723
diff
changeset
|
75 # import hashlib |
| 28692 | 76 # predicates = [k for k in dir(stringprep) if k.startswith("in_table")] |
| 77 # predicates.sort() | |
| 78 # for p in predicates: | |
| 79 # f = getattr(stringprep, p) | |
| 80 # # Collect all BMP code points | |
| 81 # data = ["0"] * 0x10000 | |
| 82 # for i in range(0x10000): | |
| 83 # if f(unichr(i)): | |
| 84 # data[i] = "1" | |
| 85 # data = "".join(data) | |
|
38052
32a187f3d5ba
In stdlib, use hashlib instead of deprecated md5 and sha modules.
Georg Brandl <georg@python.org>
parents:
30723
diff
changeset
|
86 # h = hashlib.sha1() |
| 28692 | 87 # h.update(data) |
|
38052
32a187f3d5ba
In stdlib, use hashlib instead of deprecated md5 and sha modules.
Georg Brandl <georg@python.org>
parents:
30723
diff
changeset
|
88 # print p, h.hexdigest() |
