cpython: e1457e9f340f (original) (raw)
Mercurial > cpython
changeset 95623:e1457e9f340f
#11754: test contents of string module attributes. As noted in the comment, while the order of the items in the attributes is not technically guaranteed, after all this time there is almost certainly user code out there that relies on it, so we might as well test for it. Patch by Chalmer Lowe. [#11754]
R David Murray rdmurray@bitdance.com | |
---|---|
date | Mon, 13 Apr 2015 20:04:29 -0400 |
parents | 4dd6c8dc34ff |
children | 4f90751edb4f |
files | Lib/test/test_string.py Misc/ACKS |
diffstat | 2 files changed, 14 insertions(+), 9 deletions(-)[+] [-] Lib/test/test_string.py 22 Misc/ACKS 1 |
line wrap: on
line diff
--- a/Lib/test/test_string.py +++ b/Lib/test/test_string.py @@ -4,15 +4,19 @@ import unittest, string class ModuleTest(unittest.TestCase): def test_attrs(self):
string.whitespace[](#l1.7)
string.ascii_lowercase[](#l1.8)
string.ascii_uppercase[](#l1.9)
string.ascii_letters[](#l1.10)
string.digits[](#l1.11)
string.hexdigits[](#l1.12)
string.octdigits[](#l1.13)
string.punctuation[](#l1.14)
string.printable[](#l1.15)
# While the exact order of the items in these attributes is not[](#l1.16)
# technically part of the "language spec", in practice there is almost[](#l1.17)
# certainly user code that depends on the order, so de-facto it *is*[](#l1.18)
# part of the spec.[](#l1.19)
self.assertEqual(string.whitespace, ' \t\n\r\x0b\x0c')[](#l1.20)
self.assertEqual(string.ascii_lowercase, 'abcdefghijklmnopqrstuvwxyz')[](#l1.21)
self.assertEqual(string.ascii_uppercase, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')[](#l1.22)
self.assertEqual(string.ascii_letters, string.ascii_lowercase + string.ascii_uppercase)[](#l1.23)
self.assertEqual(string.digits, '0123456789')[](#l1.24)
self.assertEqual(string.hexdigits, string.digits + 'abcdefABCDEF')[](#l1.25)
self.assertEqual(string.octdigits, '01234567')[](#l1.26)
self.assertEqual(string.punctuation, '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~')[](#l1.27)
self.assertEqual(string.printable, string.digits + string.ascii_lowercase + string.ascii_uppercase + string.punctuation + string.whitespace)[](#l1.28)
def test_capwords(self): self.assertEqual(string.capwords('abc def ghi'), 'Abc Def Ghi')
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -850,6 +850,7 @@ Anne Lord Tom Loredo Justin Love Ned Jackson Lovely +Chalmer Lowe Jason Lowe Tony Lownds Ray Loyzaga