Exemple #1
0
 def test_fake_listdir_in(self):
     my_dir = os.path.dirname(__file__)
     stubs.FakeFile.is_file_accessible(my_dir, False).AndReturn(
         stubs.FakeFile.Visibility.OK)
     for f in os.listdir(my_dir):
         p = os.path.join(my_dir, f)
         stubs.FakeFile.is_file_accessible(p).AndReturn(
             stubs.FakeFile.Visibility.OK)
     self.mox.ReplayAll()
     fake_listdir = stubs.make_fake_listdir(os.listdir)
     files = fake_listdir(os.path.dirname(__file__))
     self.assertIn(os.path.basename(__file__), files)
     self.mox.VerifyAll()
 'os':
 ModuleOverridePolicy(
     default_stub=stubs.os_error_not_implemented,
     whitelist=[
         'altsep', 'chown', 'close', 'curdir', 'defpath', 'devnull',
         'environ', 'error', 'execv', 'fchmod', 'fchown', 'fdopen', 'fork',
         'fstat', 'ftruncate', 'getcwd', 'getcwdu', 'getenv',
         '_get_exports_list', 'kill', 'lchown', 'name', 'open', 'pardir',
         'path', 'pathsep', 'popen', 'readline', 'sep', 'setuid',
         'stat_float_times', 'stat_result', 'strerror', 'sys', 'waitpid',
         'walk', 'readlink'
     ],
     overrides={
         'access': stubs.fake_access,
         'chmod': stubs.RestrictedPathFunction(os.chmod, for_write=True),
         'listdir': stubs.make_fake_listdir(os.listdir),
         # Alias lstat() to stat() to match the behavior in production.
         'lstat': stubs.RestrictedPathFunction(os.stat),
         'makedirs': stubs.RestrictedPathFunction(os.makedirs,
                                                  for_write=True),
         'mkdir': stubs.RestrictedPathFunction(os.mkdir, for_write=True),
         'open': stubs.fake_open,
         'stat': stubs.RestrictedPathFunction(os.stat),
         'uname': stubs.fake_uname,
         'getpid': stubs.return_minus_one,
         'getppid': stubs.return_minus_one,
         'getpgrp': stubs.return_minus_one,
         'getgid': stubs.return_minus_one,
         'getegid': stubs.return_minus_one,
         'geteuid': stubs.return_minus_one,
         'getuid': stubs.return_minus_one,