forked from skulpt/skulpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_exit.py
45 lines (38 loc) · 1.17 KB
/
test_exit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
__author__ = "leszek"
import unittest
class ExitTest(unittest.TestCase):
def test_exit(self):
try:
exit()
self.fail("Should not reach line after exit")
except SystemExit as e:
return
self.fail("Test should have returned")
def test_exit_not_exception(self):
try:
try:
exit()
except Exception as e:
self.fail("except Exception should not catch SystemExit")
self.fail("Should not reach line after exit")
except SystemExit as e:
return
self.fail("Test should have returned")
def test_exit_in_func(self):
try:
def foo():
exit()
exit()
self.fail("Should not reach line after exit")
except SystemExit as e:
return
self.fail("Test should have returned")
def test_import_exit(self):
try:
import exiting_module
self.fail("Should not reach line after import")
except SystemExit as e:
return
self.fail("Test should have returned")
if __name__ == "__main__":
unittest.main()