diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2020-04-03 01:03:26 +0100 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2020-04-03 01:03:26 +0100 |
commit | 2bb8b3d88a191d96c6693007ad79ae808f872941 (patch) | |
tree | 7244b1925cea73e1a48e2e1b73786aff8ce80c15 | |
parent | be943c9fd48b3e8d7f3e5be5b2fd251f958c63f7 (diff) | |
download | unit-2bb8b3d88a191d96c6693007ad79ae808f872941.tar.gz unit-2bb8b3d88a191d96c6693007ad79ae808f872941.tar.bz2 |
Tests: minor fixes.
Diffstat (limited to '')
-rw-r--r-- | test/test_java_websockets.py | 2 | ||||
-rw-r--r-- | test/test_return.py | 1 | ||||
-rw-r--r-- | test/unit/main.py | 26 |
3 files changed, 20 insertions, 9 deletions
diff --git a/test/test_java_websockets.py b/test/test_java_websockets.py index d75ee3a6..e0dbf539 100644 --- a/test/test_java_websockets.py +++ b/test/test_java_websockets.py @@ -22,7 +22,7 @@ class TestJavaWebsockets(TestApplicationJava): ) self.skip_alerts.extend( - [r'last message send failed', r'socket close\(\d+\) failed'] + [r'socket close\(\d+\) failed'] ) def close_connection(self, sock): diff --git a/test/test_return.py b/test/test_return.py index bd65b9bb..fcb51745 100644 --- a/test/test_return.py +++ b/test/test_return.py @@ -183,6 +183,7 @@ Connection: close check_error({"return": []}) check_error({"return": 80.1}) check_error({"return": 1000}) + check_error({"return": -1}) check_error({"return": 200, "share": "/blah"}) self.assertIn( diff --git a/test/unit/main.py b/test/unit/main.py index 49c1eed3..060a03a5 100644 --- a/test/unit/main.py +++ b/test/unit/main.py @@ -199,7 +199,7 @@ class TestUnit(unittest.TestCase): self.skip_sanitizer = False def tearDown(self): - self.stop() + stop_errs = self.stop() # detect errors and failures for current test @@ -234,11 +234,19 @@ class TestUnit(unittest.TestCase): else: self._print_log() + self.assertListEqual(stop_errs, [None, None], 'stop errors') + def stop(self): - self._stop() - self.stop_processes() + errors = [] + + errors.append(self._stop()) + + errors.append(self.stop_processes()) + atexit.unregister(self.stop) + return errors + def _stop(self): if self._p.poll() is not None: return @@ -249,12 +257,10 @@ class TestUnit(unittest.TestCase): try: retcode = p.wait(15) if retcode: - self.fail( - "Child process terminated with code " + str(retcode) - ) + return 'Child process terminated with code ' + str(retcode) except: p.kill() - self.fail("Could not terminate unit") + return 'Could not terminate unit' def run_process(self, target, *args): if not hasattr(self, '_processes'): @@ -269,13 +275,17 @@ class TestUnit(unittest.TestCase): if not hasattr(self, '_processes'): return + fail = False for process in self._processes: if process.is_alive(): process.terminate() process.join(timeout=15) if process.is_alive(): - self.fail('Fail to stop process') + fail = True + + if fail: + return 'Fail to stop process' def waitforfiles(self, *files): for i in range(50): |