MCPcopy Index your code
hub / github.com/python/cpython / basic_test

Method basic_test

Lib/test/test_configparser.py:70–292  ·  view source on GitHub ↗
(self, cf)

Source from the content-addressed store, hash-verified

68class BasicTestCase(CfgParserTestCaseClass):
69
70 def basic_test(self, cf):
71 E = ['Commented Bar',
72 'Foo Bar',
73 'Internationalized Stuff',
74 'Long Line',
75 'Section\\with$weird%characters[\t',
76 'Spaces',
77 'Spacey Bar',
78 'Spacey Bar From The Beginning',
79 'Types',
80 'This One Has A ] In It',
81 ]
82
83 if self.allow_no_value:
84 E.append('NoValue')
85 E.sort()
86 F = [('baz', 'qwe'), ('foo', 'bar3')]
87
88 # API access
89 L = cf.sections()
90 L.sort()
91 eq = self.assertEqual
92 eq(L, E)
93 L = cf.items('Spacey Bar From The Beginning')
94 L.sort()
95 eq(L, F)
96
97 # mapping access
98 L = [section for section in cf]
99 L.sort()
100 E.append(self.default_section)
101 E.sort()
102 eq(L, E)
103 L = cf['Spacey Bar From The Beginning'].items()
104 L = sorted(list(L))
105 eq(L, F)
106 L = cf.items()
107 L = sorted(list(L))
108 self.assertEqual(len(L), len(E))
109 for name, section in L:
110 eq(name, section.name)
111 eq(cf.defaults(), cf[self.default_section])
112
113 # The use of spaces in the section names serves as a
114 # regression test for SourceForge bug #583248:
115 # https://bugs.python.org/issue583248
116
117 # API access
118 eq(cf.get('Foo Bar', 'foo'), 'bar1')
119 eq(cf.get('Spacey Bar', 'foo'), 'bar2')
120 eq(cf.get('Spacey Bar From The Beginning', 'foo'), 'bar3')
121 eq(cf.get('Spacey Bar From The Beginning', 'baz'), 'qwe')
122 eq(cf.get('Commented Bar', 'foo'), 'bar4')
123 eq(cf.get('Commented Bar', 'baz'), 'qwe')
124 eq(cf.get('Spaces', 'key with spaces'), 'value')
125 eq(cf.get('Spaces', 'another with spaces'), 'splat!')
126 eq(cf.getint('Types', 'int'), 42)
127 eq(cf.get('Types', 'int'), "42")

Callers 2

test_basicMethod · 0.95
test_basic_from_dictMethod · 0.95

Calls 15

eqFunction · 0.85
listClass · 0.85
defaultsMethod · 0.80
getfloatMethod · 0.80
assertTrueMethod · 0.80
remove_sectionMethod · 0.80
assertFalseMethod · 0.80
appendMethod · 0.45
sortMethod · 0.45
sectionsMethod · 0.45
itemsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected