diff options
author | R David Murray <rdmurray@bitdance.com> | 2015-04-14 00:04:29 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2015-04-14 00:04:29 (GMT) |
commit | 0a8f43e85a002db670f358b65fba1e094fd7f4b5 (patch) | |
tree | 3bf5bbdcde089dd2d1fc4dae5436a4dc298cd217 /Lib/test/test_string.py | |
parent | 5aec1a44e89d31cc000d47c8ac0afdb6a280e765 (diff) | |
download | cpython-0a8f43e85a002db670f358b65fba1e094fd7f4b5.zip cpython-0a8f43e85a002db670f358b65fba1e094fd7f4b5.tar.gz cpython-0a8f43e85a002db670f358b65fba1e094fd7f4b5.tar.bz2 |
#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.
Diffstat (limited to 'Lib/test/test_string.py')
-rw-r--r-- | Lib/test/test_string.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/Lib/test/test_string.py b/Lib/test/test_string.py index 85b5434..5d37e16 100644 --- 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 - string.ascii_lowercase - string.ascii_uppercase - string.ascii_letters - string.digits - string.hexdigits - string.octdigits - string.punctuation - string.printable + # While the exact order of the items in these attributes is not + # technically part of the "language spec", in practice there is almost + # certainly user code that depends on the order, so de-facto it *is* + # part of the spec. + self.assertEqual(string.whitespace, ' \t\n\r\x0b\x0c') + self.assertEqual(string.ascii_lowercase, 'abcdefghijklmnopqrstuvwxyz') + self.assertEqual(string.ascii_uppercase, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') + self.assertEqual(string.ascii_letters, string.ascii_lowercase + string.ascii_uppercase) + self.assertEqual(string.digits, '0123456789') + self.assertEqual(string.hexdigits, string.digits + 'abcdefABCDEF') + self.assertEqual(string.octdigits, '01234567') + self.assertEqual(string.punctuation, '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~') + self.assertEqual(string.printable, string.digits + string.ascii_lowercase + string.ascii_uppercase + string.punctuation + string.whitespace) def test_capwords(self): self.assertEqual(string.capwords('abc def ghi'), 'Abc Def Ghi') |