diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_snekbox.py | 46 | 
1 files changed, 23 insertions, 23 deletions
| diff --git a/tests/test_snekbox.py b/tests/test_snekbox.py index c08178f..46319d6 100644 --- a/tests/test_snekbox.py +++ b/tests/test_snekbox.py @@ -7,44 +7,44 @@ nsjail = NsJail()  class SnekTests(unittest.TestCase):      def test_nsjail(self): -        result = nsjail.python3('print("test")') -        self.assertEquals(result.strip(), 'test') +        result = nsjail.python3("print('test')") +        self.assertEquals(result.strip(), "test")      # def test_memory_error(self): -    #     code = ('x = "*"\n' -    #             'while True:\n' -    #             '    x = x * 99\n') +    #     code = ("x = "*"\n" +    #             "while True:\n" +    #             "    x = x * 99\n")      #     result = nsjail.python3(code) -    #     self.assertEquals(result.strip(), 'timed out or memory limit exceeded') +    #     self.assertEquals(result.strip(), "timed out or memory limit exceeded")      def test_timeout(self):          code = ( -            'x = "*"\n' -            'while True:\n' -            '    try:\n' -            '        x = x * 99\n' -            '    except:\n' -            '        continue\n' +            "x = '*'\n" +            "while True:\n" +            "    try:\n" +            "        x = x * 99\n" +            "    except:\n" +            "        continue\n"          )          result = nsjail.python3(code) -        self.assertEquals(result.strip(), 'timed out or memory limit exceeded') +        self.assertEquals(result.strip(), "timed out or memory limit exceeded")      def test_kill(self): -        code = ('import subprocess\n' -                'print(subprocess.check_output("kill -9 6", shell=True).decode())') +        code = ("import subprocess\n" +                "print(subprocess.check_output('kill -9 6', shell=True).decode())")          result = nsjail.python3(code) -        if 'ModuleNotFoundError' in result.strip(): -            self.assertIn('ModuleNotFoundError', result.strip()) +        if "ModuleNotFoundError" in result.strip(): +            self.assertIn("ModuleNotFoundError", result.strip())          else: -            self.assertIn('(PIDs left: 0)', result.strip()) +            self.assertIn("(PIDs left: 0)", result.strip())      def test_forkbomb(self): -        code = ('import os\n' -                'while 1:\n' -                '    os.fork()') +        code = ("import os\n" +                "while 1:\n" +                "    os.fork()")          result = nsjail.python3(code) -        self.assertIn('Resource temporarily unavailable', result.strip()) +        self.assertIn("Resource temporarily unavailable", result.strip())      def test_juan_golf(self):  # in honour of Juan          code = ("func = lambda: None\n" @@ -53,4 +53,4 @@ class SnekTests(unittest.TestCase):                  "exec(bytecode)")          result = nsjail.python3(code) -        self.assertEquals('unknown error, code: 111', result.strip()) +        self.assertEquals("unknown error, code: 111", result.strip()) | 
