aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_timed.py
diff options
context:
space:
mode:
authorGravatar Mark <[email protected]>2023-09-16 11:51:40 -0700
committerGravatar Mark <[email protected]>2023-10-27 11:59:01 -0700
commit56376361a941383555e2db129baf34250d409b06 (patch)
treebf82c21e75140088f769ab35ff0e3a3646a752ba /tests/test_timed.py
parentMerge #195 - Python 3.12 (diff)
Refactor modules into subpackages
Diffstat (limited to 'tests/test_timed.py')
-rw-r--r--tests/test_timed.py30
1 files changed, 0 insertions, 30 deletions
diff --git a/tests/test_timed.py b/tests/test_timed.py
deleted file mode 100644
index e46bd37..0000000
--- a/tests/test_timed.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import math
-import time
-from unittest import TestCase
-
-from snekbox.utils.timed import time_limit
-
-
-class TimedTests(TestCase):
- def test_sleep(self):
- """Test that a sleep can be interrupted."""
- _finished = False
- start = time.perf_counter()
- with self.assertRaises(TimeoutError):
- with time_limit(1):
- time.sleep(2)
- _finished = True
- end = time.perf_counter()
- self.assertLess(end - start, 2)
- self.assertFalse(_finished)
-
- def test_iter(self):
- """Test that a long-running built-in function can be interrupted."""
- _result = 0
- start = time.perf_counter()
- with self.assertRaises(TimeoutError):
- with time_limit(1):
- _result = math.factorial(2**30)
- end = time.perf_counter()
- self.assertEqual(_result, 0)
- self.assertLess(end - start, 2)