示例#1
0
 def test_fake_open_write(self):
   self.mox.ReplayAll()
   with self.assertRaises(OSError) as cm:
     stubs.fake_open(__file__, os.O_RDWR)
   self.mox.VerifyAll()
   e = cm.exception
   self.assertEqual(errno.EROFS, e.errno)
   self.assertEqual('Read-only file system', e.strerror)
   self.assertEqual(__file__, e.filename)
   self.mox.VerifyAll()
示例#2
0
 def test_fake_open_inaccessible(self):
   stubs.FakeFile.is_file_accessible(__file__).AndReturn(False)
   self.mox.ReplayAll()
   with self.assertRaises(OSError) as cm:
     stubs.fake_open(__file__, os.O_RDONLY)
   self.mox.VerifyAll()
   e = cm.exception
   self.assertEqual(errno.ENOENT, e.errno)
   self.assertEqual('No such file or directory', e.strerror)
   self.assertEqual(__file__, e.filename)
   self.mox.VerifyAll()
示例#3
0
 def test_fake_open_inaccessible(self):
   stubs.FakeFile.is_file_accessible(__file__).AndReturn(False)
   logging.info('Sandbox prevented access to file "%s"', __file__)
   logging.info('If it is a static file, check that '
                '`application_readable: true` is set in your app.yaml')
   self.mox.ReplayAll()
   with self.assertRaises(OSError) as cm:
     stubs.fake_open(__file__, os.O_RDONLY)
   self.mox.VerifyAll()
   e = cm.exception
   self.assertEqual(errno.ENOENT, e.errno)
   self.assertEqual('No such file or directory', e.strerror)
   self.assertEqual(__file__, e.filename)
   self.mox.VerifyAll()
示例#4
0
 def test_fake_open_accessible(self):
   stubs.FakeFile.is_file_accessible(__file__).AndReturn(True)
   self.mox.ReplayAll()
   os.close(stubs.fake_open(__file__, os.O_RDONLY))
   self.mox.VerifyAll()