Back to index

python3.2  3.2.2
Public Member Functions
test.test_unicode.StringModuleTest Class Reference

List of all members.

Public Member Functions

def test_formatter_parser
def test_formatter_field_name_split

Detailed Description

Definition at line 1551 of file test_unicode.py.


Member Function Documentation

Definition at line 1585 of file test_unicode.py.

01585 
01586     def test_formatter_field_name_split(self):
01587         def split(name):
01588             items = list(_string.formatter_field_name_split(name))
01589             items[1] = list(items[1])
01590             return items
01591         self.assertEqual(split("obj"), ["obj", []])
01592         self.assertEqual(split("obj.arg"), ["obj", [(True, 'arg')]])
01593         self.assertEqual(split("obj[key]"), ["obj", [(False, 'key')]])
01594         self.assertEqual(split("obj.arg[key1][key2]"), [
01595             "obj",
01596             [(True, 'arg'),
01597              (False, 'key1'),
01598              (False, 'key2'),
01599             ]])
01600         self.assertRaises(TypeError, _string.formatter_field_name_split, 1)
01601 

Here is the call graph for this function:

Definition at line 1552 of file test_unicode.py.

01552 
01553     def test_formatter_parser(self):
01554         def parse(format):
01555             return list(_string.formatter_parser(format))
01556 
01557         formatter = parse("prefix {2!s}xxx{0:^+10.3f}{obj.attr!s} {z[0]!s:10}")
01558         self.assertEqual(formatter, [
01559             ('prefix ', '2', '', 's'),
01560             ('xxx', '0', '^+10.3f', None),
01561             ('', 'obj.attr', '', 's'),
01562             (' ', 'z[0]', '10', 's'),
01563         ])
01564 
01565         formatter = parse("prefix {} suffix")
01566         self.assertEqual(formatter, [
01567             ('prefix ', '', '', None),
01568             (' suffix', None, None, None),
01569         ])
01570 
01571         formatter = parse("str")
01572         self.assertEqual(formatter, [
01573             ('str', None, None, None),
01574         ])
01575 
01576         formatter = parse("")
01577         self.assertEqual(formatter, [])
01578 
01579         formatter = parse("{0}")
01580         self.assertEqual(formatter, [
01581             ('', '0', '', None),
01582         ])
01583 
01584         self.assertRaises(TypeError, _string.formatter_parser, 1)

Here is the call graph for this function:


The documentation for this class was generated from the following file: