##// END OF EJS Templates
Make sure it exited quickly.
Itamar Turner-Trauring -
Show More
@@ -116,7 +116,6 b' class SubProcessTestCase(tt.TempFileMixin):'
116 subprocess is interrupted.
116 subprocess is interrupted.
117 """
117 """
118 if threading.main_thread() != threading.current_thread():
118 if threading.main_thread() != threading.current_thread():
119 raise RuntimeEror("Not in main thread")
120 raise nt.SkipTest("Can't run this test if not in main thread.")
119 raise nt.SkipTest("Can't run this test if not in main thread.")
121
120
122 def interrupt():
121 def interrupt():
@@ -125,14 +124,19 b' class SubProcessTestCase(tt.TempFileMixin):'
125 interrupt_main()
124 interrupt_main()
126
125
127 threading.Thread(target=interrupt).start()
126 threading.Thread(target=interrupt).start()
127 start = time.time()
128 try:
128 try:
129 status = system('%s -c "import time; time.sleep(5)"' % python)
129 status = system('%s -c "import time; time.sleep(5)"' % python)
130 except KeyboardInterrupt:
130 except KeyboardInterrupt:
131 # Success!
131 # Success!
132 return
132 return
133 end = time.time()
133 self.assertNotEqual(
134 self.assertNotEqual(
134 status, 0, "The process wasn't interrupted. Status: %s" % (status,)
135 status, 0, "The process wasn't interrupted. Status: %s" % (status,)
135 )
136 )
137 self.assertTrue(
138 end - start < 2, "Process didn't die quickly: %s" % (end - start)
139 )
136
140
137 def test_getoutput(self):
141 def test_getoutput(self):
138 out = getoutput('%s "%s"' % (python, self.fname))
142 out = getoutput('%s "%s"' % (python, self.fname))
General Comments 0
You need to be logged in to leave comments. Login now