Tests: minor fixes.
This commit is contained in:
@@ -22,7 +22,7 @@ class TestJavaWebsockets(TestApplicationJava):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.skip_alerts.extend(
|
self.skip_alerts.extend(
|
||||||
[r'last message send failed', r'socket close\(\d+\) failed']
|
[r'socket close\(\d+\) failed']
|
||||||
)
|
)
|
||||||
|
|
||||||
def close_connection(self, sock):
|
def close_connection(self, sock):
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ Connection: close
|
|||||||
check_error({"return": []})
|
check_error({"return": []})
|
||||||
check_error({"return": 80.1})
|
check_error({"return": 80.1})
|
||||||
check_error({"return": 1000})
|
check_error({"return": 1000})
|
||||||
|
check_error({"return": -1})
|
||||||
check_error({"return": 200, "share": "/blah"})
|
check_error({"return": 200, "share": "/blah"})
|
||||||
|
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ class TestUnit(unittest.TestCase):
|
|||||||
self.skip_sanitizer = False
|
self.skip_sanitizer = False
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.stop()
|
stop_errs = self.stop()
|
||||||
|
|
||||||
# detect errors and failures for current test
|
# detect errors and failures for current test
|
||||||
|
|
||||||
@@ -234,11 +234,19 @@ class TestUnit(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
self._print_log()
|
self._print_log()
|
||||||
|
|
||||||
|
self.assertListEqual(stop_errs, [None, None], 'stop errors')
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._stop()
|
errors = []
|
||||||
self.stop_processes()
|
|
||||||
|
errors.append(self._stop())
|
||||||
|
|
||||||
|
errors.append(self.stop_processes())
|
||||||
|
|
||||||
atexit.unregister(self.stop)
|
atexit.unregister(self.stop)
|
||||||
|
|
||||||
|
return errors
|
||||||
|
|
||||||
def _stop(self):
|
def _stop(self):
|
||||||
if self._p.poll() is not None:
|
if self._p.poll() is not None:
|
||||||
return
|
return
|
||||||
@@ -249,12 +257,10 @@ class TestUnit(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
retcode = p.wait(15)
|
retcode = p.wait(15)
|
||||||
if retcode:
|
if retcode:
|
||||||
self.fail(
|
return 'Child process terminated with code ' + str(retcode)
|
||||||
"Child process terminated with code " + str(retcode)
|
|
||||||
)
|
|
||||||
except:
|
except:
|
||||||
p.kill()
|
p.kill()
|
||||||
self.fail("Could not terminate unit")
|
return 'Could not terminate unit'
|
||||||
|
|
||||||
def run_process(self, target, *args):
|
def run_process(self, target, *args):
|
||||||
if not hasattr(self, '_processes'):
|
if not hasattr(self, '_processes'):
|
||||||
@@ -269,13 +275,17 @@ class TestUnit(unittest.TestCase):
|
|||||||
if not hasattr(self, '_processes'):
|
if not hasattr(self, '_processes'):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
fail = False
|
||||||
for process in self._processes:
|
for process in self._processes:
|
||||||
if process.is_alive():
|
if process.is_alive():
|
||||||
process.terminate()
|
process.terminate()
|
||||||
process.join(timeout=15)
|
process.join(timeout=15)
|
||||||
|
|
||||||
if process.is_alive():
|
if process.is_alive():
|
||||||
self.fail('Fail to stop process')
|
fail = True
|
||||||
|
|
||||||
|
if fail:
|
||||||
|
return 'Fail to stop process'
|
||||||
|
|
||||||
def waitforfiles(self, *files):
|
def waitforfiles(self, *files):
|
||||||
for i in range(50):
|
for i in range(50):
|
||||||
|
|||||||
Reference in New Issue
Block a user