def setUp(self): self.backup = [] # paranoid check self.cfgstr = str(cfg) # clean up externals cfg for proper testing if cfg.has_section('externals'): self.backup = copy.deepcopy(cfg.items('externals')) cfg.remove_section('externals')
def tearDown(self): if len(self.backup): # wipe existing one completely if cfg.has_section('externals'): cfg.remove_section('externals') cfg.add_section('externals') for o,v in self.backup: cfg.set('externals', o,v) # paranoid check # since order can't be guaranteed, lets check # each item after sorting self.assertEqual(sorted(self.cfgstr.split('\n')), sorted(str(cfg).split('\n')))
def tearDown(self): if len(self.backup): # wipe existing one completely if cfg.has_section('externals'): cfg.remove_section('externals') cfg.add_section('externals') for o, v in self.backup: cfg.set('externals', o, v) # paranoid check # since order can't be guaranteed, lets check # each item after sorting self.assertEqual(sorted(self.cfgstr.split('\n')), sorted(str(cfg).split('\n')))