Fixes to failing-test teardowns to avoid more exceptions or hangs
(cherry picked from commit 734f3d6f42ef1564f473fee5526e0354fc8196fc) Conflicts: test.py
This commit is contained in:
parent
212fe74f09
commit
e0be91a4c9
8
test.py
8
test.py
|
@ -28,6 +28,7 @@ import sys
|
||||||
import unittest
|
import unittest
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import paramiko
|
import paramiko
|
||||||
|
import threading
|
||||||
|
|
||||||
sys.path.append('tests')
|
sys.path.append('tests')
|
||||||
|
|
||||||
|
@ -141,7 +142,12 @@ def main():
|
||||||
if len(args) > 0:
|
if len(args) > 0:
|
||||||
filter = '|'.join(args)
|
filter = '|'.join(args)
|
||||||
suite = filter_suite_by_re(suite, filter)
|
suite = filter_suite_by_re(suite, filter)
|
||||||
runner.run(suite)
|
result = runner.run(suite)
|
||||||
|
# Clean up stale threads from poorly cleaned-up tests.
|
||||||
|
# TODO: make that not a problem, jeez
|
||||||
|
for thread in threading.enumerate():
|
||||||
|
if thread is not threading.currentThread():
|
||||||
|
thread._Thread__stop()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -68,11 +68,9 @@ class SSHClientTest (unittest.TestCase):
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
if hasattr(self, 'tc'):
|
for attr in "tc ts socks sockl".split():
|
||||||
self.tc.close()
|
if hasattr(self, attr):
|
||||||
self.ts.close()
|
getattr(self, attr).close()
|
||||||
self.socks.close()
|
|
||||||
self.sockl.close()
|
|
||||||
|
|
||||||
def _run(self):
|
def _run(self):
|
||||||
self.socks, addr = self.sockl.accept()
|
self.socks, addr = self.sockl.accept()
|
||||||
|
|
Loading…
Reference in New Issue