Kaydet (Commit) 0a8f43e8 authored tarafından R David Murray's avatar R David Murray

#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.
üst 5aec1a44
...@@ -4,15 +4,19 @@ import unittest, string ...@@ -4,15 +4,19 @@ import unittest, string
class ModuleTest(unittest.TestCase): class ModuleTest(unittest.TestCase):
def test_attrs(self): def test_attrs(self):
string.whitespace # While the exact order of the items in these attributes is not
string.ascii_lowercase # technically part of the "language spec", in practice there is almost
string.ascii_uppercase # certainly user code that depends on the order, so de-facto it *is*
string.ascii_letters # part of the spec.
string.digits self.assertEqual(string.whitespace, ' \t\n\r\x0b\x0c')
string.hexdigits self.assertEqual(string.ascii_lowercase, 'abcdefghijklmnopqrstuvwxyz')
string.octdigits self.assertEqual(string.ascii_uppercase, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
string.punctuation self.assertEqual(string.ascii_letters, string.ascii_lowercase + string.ascii_uppercase)
string.printable 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): def test_capwords(self):
self.assertEqual(string.capwords('abc def ghi'), 'Abc Def Ghi') self.assertEqual(string.capwords('abc def ghi'), 'Abc Def Ghi')
......
...@@ -850,6 +850,7 @@ Anne Lord ...@@ -850,6 +850,7 @@ Anne Lord
Tom Loredo Tom Loredo
Justin Love Justin Love
Ned Jackson Lovely Ned Jackson Lovely
Chalmer Lowe
Jason Lowe Jason Lowe
Tony Lownds Tony Lownds
Ray Loyzaga Ray Loyzaga
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment