Test that we can't write files

This commit is contained in:
Ned Batchelder
2013-02-08 10:34:03 -05:00
parent 9cc43f1d9b
commit 4bb5d14f70

View File

@@ -1,3 +1,5 @@
"""Test jailpy.py"""
import textwrap
import unittest
from nose.plugins.skip import SkipTest
@@ -53,6 +55,18 @@ class TestLimits(unittest.TestCase):
self.assertNotEqual(res.status, 0)
self.assertEqual(res.stdout, "")
def test_cant_write_files(self):
res = jailpy(dedent("""\
print "Trying"
with open("mydata.txt", "w") as f:
f.write("hello")
with open("mydata.txt") as f2:
print "Got this:", f2.read()
"""))
self.assertNotEqual(res.status, 0)
self.assertEqual(res.stdout, "Trying\n")
self.assertIn("ermission denied", res.stderr)
# TODO: write files
# TODO: read network
# TODO: fork