diff options
author | Ales Kozumplik <akozumpl@redhat.com> | 2011-07-26 13:25:53 +0200 |
---|---|---|
committer | Ales Kozumplik <akozumpl@redhat.com> | 2011-07-27 08:25:39 +0200 |
commit | 6ded1c973588a17a62875041adca29e7739d9313 (patch) | |
tree | d906179cd2d64c952b84d5b0fc8b013c92cea8c4 /tests/mock/disk.py | |
parent | 6caf7e595148a329b4cce915f9d872e196447f9e (diff) | |
download | anaconda-6ded1c973588a17a62875041adca29e7739d9313.tar.gz anaconda-6ded1c973588a17a62875041adca29e7739d9313.tar.xz anaconda-6ded1c973588a17a62875041adca29e7739d9313.zip |
ut: cleanup the taking-over-io mechanism.
1) Move the functionality from mock.DiskIO to mock.TestCase itself.
2) Use already existing mechanism (tearDownModules()) for cleaning up
after we override functions in widely used modules.
Diffstat (limited to 'tests/mock/disk.py')
-rw-r--r-- | tests/mock/disk.py | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/tests/mock/disk.py b/tests/mock/disk.py index fbd61815f..4fe4c7603 100644 --- a/tests/mock/disk.py +++ b/tests/mock/disk.py @@ -18,14 +18,7 @@ from StringIO import StringIO import fnmatch -import glob -import os.path - -_orig_glob_glob = glob.glob -_orig_open = open -_orig_os_listdir = os.listdir -_orig_os_path_exists = os.path.exists -_orig_os_path_isdir = os.path.isdir +import os class DiskIO(object): """Simple object to simplify mocking of file operations in Mock @@ -133,23 +126,3 @@ class DiskIO(object): def os_access(self, path, mode): return self.path_exists(path) - - def take_over_module(self, module): - """ Trick module into using this object as the filesystem. - - This is achieved by overriding the module's 'open' binding as well - as some bindings in os.path. - """ - module.open = self.open - module.glob.glob = self.glob_glob - module.os.listdir = self.os_listdir - module.os.path.exists = self.os_path_exists - module.os.path.isdir = self.os_path_isdir - - @staticmethod - def restore_module(module): - module.open = _orig_open - module.glob.glob = _orig_glob_glob - module.os.listdir = _orig_os_listdir - module.os.path.exists = _orig_os_path_exists - module.os.path.isdir = _orig_os_path_isdir |