-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathtest.py
32 lines (27 loc) · 1.08 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright 2022 The go-python Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
import string
print("globals:")
for name in ("whitespace",
"ascii_lowercase",
"ascii_uppercase",
"ascii_letters",
"digits",
"hexdigits",
"octdigits",
"punctuation",
"printable"):
v = getattr(string, name)
print("\nstring.%s:\n%s" % (name,repr(v)))
def assertEqual(x, y):
assert x == y, "got: %s, want: %s" % (repr(x), repr(y))
assertEqual(string.capwords('abc def ghi'), 'Abc Def Ghi')
assertEqual(string.capwords('abc\tdef\nghi'), 'Abc Def Ghi')
assertEqual(string.capwords('abc\t def \nghi'), 'Abc Def Ghi')
assertEqual(string.capwords('ABC DEF GHI'), 'Abc Def Ghi')
assertEqual(string.capwords('ABC-DEF-GHI', '-'), 'Abc-Def-Ghi')
assertEqual(string.capwords('ABC-def DEF-ghi GHI'), 'Abc-def Def-ghi Ghi')
assertEqual(string.capwords(' aBc DeF '), 'Abc Def')
assertEqual(string.capwords('\taBc\tDeF\t'), 'Abc Def')
assertEqual(string.capwords('\taBc\tDeF\t', '\t'), '\tAbc\tDef\t')