-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
37 lines (31 loc) · 918 Bytes
/
test.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
import unittest
import subprocess
import os
import signal
import time
import fcntl
class MyTestCase(unittest.TestCase):
def test_imports(self):
import playground
print (u'\"%s\"\n\"%s\"' % (self, playground))
def test_screenshot(self):
pid = subprocess.Popen(
'python playground.py &',
shell=True,
preexec_fn=os.setsid,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
fd = pid.stdout.fileno()
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
time.sleep(5)
try:
rc = pid.stdout.read()
if 'traceback' in rc:
print(u"%s" % rc)
self.fail()
except IOError:
pass
os.killpg(pid.pid, signal.SIGTERM)
if __name__ == '__main__':
unittest.main(failfast=True)