summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtest/run.py19
-rw-r--r--test/test_proxy.py7
-rw-r--r--test/unit/main.py13
3 files changed, 18 insertions, 21 deletions
diff --git a/test/run.py b/test/run.py
index 0504a6f7..b79d0484 100755
--- a/test/run.py
+++ b/test/run.py
@@ -4,16 +4,17 @@ import unittest
import sys
import os
-loader = unittest.TestLoader()
-suite = unittest.TestSuite()
+if __name__ == '__main__':
+ loader = unittest.TestLoader()
+ suite = unittest.TestSuite()
-this_dir = os.path.dirname(__file__)
-tests = loader.discover(start_dir=this_dir)
-suite.addTests(tests)
+ this_dir = os.path.dirname(__file__)
+ tests = loader.discover(start_dir=this_dir)
+ suite.addTests(tests)
-runner = unittest.TextTestRunner(verbosity=3)
-result = runner.run(suite)
+ runner = unittest.TextTestRunner(verbosity=3)
+ result = runner.run(suite)
-ret = not (len(result.failures) == len(result.errors) == 0)
+ ret = not (len(result.failures) == len(result.errors) == 0)
-sys.exit(ret)
+ sys.exit(ret)
diff --git a/test/test_proxy.py b/test/test_proxy.py
index 4697b88f..5d158285 100644
--- a/test/test_proxy.py
+++ b/test/test_proxy.py
@@ -10,11 +10,12 @@ class TestProxy(TestApplicationPython):
SERVER_PORT = 7999
- def run_server(self):
+ @staticmethod
+ def run_server(server_port):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- server_address = ('', self.SERVER_PORT)
+ server_address = ('', server_port)
sock.bind(server_address)
sock.listen(5)
@@ -57,7 +58,7 @@ Content-Length: 10
def setUp(self):
super().setUp()
- self.run_process(self.run_server)
+ self.run_process(self.run_server, self.SERVER_PORT)
self.waitforsocket(self.SERVER_PORT)
self.assertIn(
diff --git a/test/unit/main.py b/test/unit/main.py
index ea6afd7f..37d01d3b 100644
--- a/test/unit/main.py
+++ b/test/unit/main.py
@@ -209,9 +209,7 @@ class TestUnit(unittest.TestCase):
print()
- def _run_unit():
- subprocess.call(
- [
+ self._p = Process(target=subprocess.call, args=[ [
self.unitd,
'--no-daemon',
'--modules', self.pardir + '/build',
@@ -219,10 +217,7 @@ class TestUnit(unittest.TestCase):
'--pid', self.testdir + '/unit.pid',
'--log', self.testdir + '/unit.log',
'--control', 'unix:' + self.testdir + '/control.unit.sock',
- ]
- )
-
- self._p = Process(target=_run_unit)
+ ] ])
self._p.start()
if not self.waitforfiles(
@@ -299,11 +294,11 @@ class TestUnit(unittest.TestCase):
if found:
print('skipped.')
- def run_process(self, target):
+ def run_process(self, target, *args):
if not hasattr(self, '_processes'):
self._processes = []
- process = Process(target=target)
+ process = Process(target=target, args=args)
process.start()
self._processes.append(process)