def setUp(self): self.filesystem = fake_filesystem.FakeFilesystem(path_separator='/') self.glob = fake_filesystem_glob.FakeGlobModule(self.filesystem) directory = './xyzzy' self.filesystem.CreateDirectory(directory) self.filesystem.CreateDirectory('%s/subdir' % directory) self.filesystem.CreateDirectory('%s/subdir2' % directory) self.filesystem.CreateFile('%s/subfile' % directory) self.filesystem.CreateFile('[Temp]')
def setUp(self): self.filesystem = fake_filesystem.FakeFilesystem() self.glob = fake_filesystem_glob.FakeGlobModule(self.filesystem) directory = './xyzzy' self.filesystem.CreateDirectory(directory) self.filesystem.CreateDirectory(os.path.join(directory, 'subdir')) self.filesystem.CreateDirectory(os.path.join(directory, 'subdir2')) self.filesystem.CreateFile(os.path.join(directory, 'subfile')) self.filesystem.CreateFile('[Temp]')
def _refresh(self): '''Renew the fake file system and set the _isStale flag to `False`.''' mock.patch.stopall() self.fs = fake_filesystem.FakeFilesystem() self.fake_os = fake_filesystem.FakeOsModule(self.fs) self.fake_glob = fake_filesystem_glob.FakeGlobModule(self.fs) self.fake_path = self.fake_os.path self.fake_shutil = fake_filesystem_shutil.FakeShutilModule(self.fs) self.fake_tempfile_ = fake_tempfile.FakeTempfileModule(self.fs) self.fake_open = fake_filesystem.FakeFileOpen(self.fs) self._isStale = False
def replaceGlobs(self, globs_): globs = globs_.copy() if self._isStale: self._refresh() if 'os' in globs: globs['os'] = fake_filesystem.FakeOsModule(self.fs) if 'glob' in globs: globs['glob'] = fake_filesystem_glob.FakeGlobModule(self.fs) if 'path' in globs: globs['path'] = fake_filesystem.FakePathModule(self.fs) if 'shutil' in globs: globs['shutil'] = fake_filesystem_shutil.FakeShutilModule(self.fs) if 'tempfile' in globs: globs['tempfile'] = fake_tempfile.FakeTempfileModule(self.fs) return globs
def _refresh(self): '''Renew the fake file system and set the _isStale flag to `False`.''' if self._stubs is not None: self._stubs.SmartUnsetAll() self._stubs = mox3.stubout.StubOutForTesting() self.fs = fake_filesystem.FakeFilesystem() self.fake_os = fake_filesystem.FakeOsModule(self.fs) self.fake_glob = fake_filesystem_glob.FakeGlobModule(self.fs) self.fake_path = self.fake_os.path self.fake_shutil = fake_filesystem_shutil.FakeShutilModule(self.fs) self.fake_tempfile_ = fake_tempfile.FakeTempfileModule(self.fs) self.fake_open = fake_filesystem.FakeFileOpen(self.fs) self._isStale = False