cleanup commented code, better reset_fs()

main
Fabien C. Y. Benureau 7 years ago
parent c76c7607f9
commit cf97f681ef
No known key found for this signature in database
GPG Key ID: C3FB5E831A249A9A

@ -46,9 +46,6 @@ def _get_local_editor():
def _editor_input(editor, initial='', suffix='.tmp'):
"""Use an editor to get input"""
str_initial = initial.encode('utf-8') # TODO: make it a configuration item
# tfile_name = '/tmp/pubs.tmp'
# with open(tfile_name, 'w') as temp_file:
# temp_file.write(str_initial)
with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as temp_file:
tfile_name = temp_file.name
temp_file.write(str_initial)

@ -101,16 +101,12 @@ class TestFakeFs(fake_filesystem_unittest.TestCase):
self.homepath = os.path.expanduser('~')
self.setUpPyfakefs()
self.reset_fs()
# self.fs.create_dir(os.path.expanduser('~'))
# self.fs.create_dir(self.rootpath)
# os.chdir(self.rootpath)
def reset_fs(self):
if self.fs.isdir(self.homepath):
self.fs.remove_object(self.homepath)
if self.fs.isdir(self.rootpath):
self.fs.remove_object(self.rootpath)
"""Reset the fake filesystem"""
for dir_name in self.fs.listdir('/'):
if dir_name not in ['var', 'tmp']:
self.fs.remove_object(os.path.join('/', dir_name))
self.fs.create_dir(os.path.expanduser('~'))
self.fs.create_dir(self.rootpath)

@ -90,4 +90,4 @@ class TestDataBroker(fake_env.TestFakeFs):
if __name__ == '__main__':
unittest.main()
unittest.main(verbosity=2)

Loading…
Cancel
Save