aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_snekbox.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_snekbox.py')
-rw-r--r--tests/test_snekbox.py60
1 files changed, 0 insertions, 60 deletions
diff --git a/tests/test_snekbox.py b/tests/test_snekbox.py
deleted file mode 100644
index e2505d6..0000000
--- a/tests/test_snekbox.py
+++ /dev/null
@@ -1,60 +0,0 @@
-import unittest
-import pytest
-import os
-import json
-
-from snekbox import Snekbox
-from rmq import Rmq
-
-r = Rmq()
-
-snek = Snekbox()
-
-
-class SnekTests(unittest.TestCase):
- def test_nsjail(self):
- result = snek.python3('print("test")')
- self.assertEquals(result.strip(), 'test')
-
- # def test_memory_error(self):
- # code = ('x = "*"\n'
- # 'while True:\n'
- # ' x = x * 99\n')
- # result = snek.python3(code)
- # 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')
-
- result = snek.python3(code)
- 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())')
- result = snek.python3(code)
- if 'ModuleNotFoundError' in result.strip():
- self.assertIn('ModuleNotFoundError', result.strip())
- else:
- self.assertIn('(PIDs left: 0)', result.strip())
-
- def test_forkbomb(self):
- code = ('import os\n'
- 'while 1:\n'
- ' os.fork()')
- result = snek.python3(code)
- self.assertIn('Resource temporarily unavailable', result.strip())
-
- def test_juan_golf(self): # in honour of Juan
- code = ("func = lambda: None\n"
- "CodeType = type(func.__code__)\n"
- "bytecode = CodeType(0,1,0,0,0,b'',(),(),(),'','',1,b'')\n"
- "exec(bytecode)")
-
- result = snek.python3(code)
- self.assertEquals('unknown error, code: 111', result.strip())