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

Method test_save

Lib/idlelib/idle_test/test_config.py:162–177  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

160 self.assertCountEqual(parser.sections(), ['Foo'])
161
162 def test_save(self):
163 with tempfile.TemporaryDirectory() as tdir:
164 path = os.path.join(tdir, 'test.cfg')
165 parser = self.new_parser(path)
166 parser.AddSection('Foo')
167 parser.SetOption('Foo', 'bar', 'true')
168
169 # Should save to path when config is not empty.
170 self.assertFalse(os.path.exists(path))
171 parser.Save()
172 self.assertTrue(os.path.exists(path))
173
174 # Should remove the file from disk when config is empty.
175 parser.remove_section('Foo')
176 parser.Save()
177 self.assertFalse(os.path.exists(path))
178
179
180class IdleConfTest(unittest.TestCase):

Callers

nothing calls this directly

Calls 9

new_parserMethod · 0.95
AddSectionMethod · 0.80
assertFalseMethod · 0.80
SaveMethod · 0.80
assertTrueMethod · 0.80
remove_sectionMethod · 0.80
joinMethod · 0.45
SetOptionMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected