From cf97f681efe2ead29fa121df698ea286c4f6b336 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Wed, 1 Aug 2018 14:37:23 +0900 Subject: [PATCH] cleanup commented code, better reset_fs() --- pubs/uis.py | 3 --- tests/fake_env.py | 12 ++++-------- tests/test_databroker.py | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/pubs/uis.py b/pubs/uis.py index 326ab25..c2a8bfc 100644 --- a/pubs/uis.py +++ b/pubs/uis.py @@ -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) diff --git a/tests/fake_env.py b/tests/fake_env.py index d8404a3..028d656 100644 --- a/tests/fake_env.py +++ b/tests/fake_env.py @@ -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) diff --git a/tests/test_databroker.py b/tests/test_databroker.py index 041ac8e..8891931 100644 --- a/tests/test_databroker.py +++ b/tests/test_databroker.py @@ -90,4 +90,4 @@ class TestDataBroker(fake_env.TestFakeFs): if __name__ == '__main__': - unittest.main() + unittest.main(verbosity=2)