commit efa38f208504975054e233aaba3dd92aa3b8b51b Author: Arturo Filastò art@fuffa.org Date: Thu Aug 22 18:36:11 2013 +0200
Only run unittests when there is something on port 8888 --- ooni/tests/test_oonibclient.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/ooni/tests/test_oonibclient.py b/ooni/tests/test_oonibclient.py index 26e2f62..47a3d47 100644 --- a/ooni/tests/test_oonibclient.py +++ b/ooni/tests/test_oonibclient.py @@ -1,3 +1,5 @@ +import socket + from twisted.trial import unittest from twisted.internet import defer
@@ -7,7 +9,15 @@ input_id = '37e60e13536f6afe47a830bfb6b371b5cf65da66d7ad65137344679b24fdccd1'
class TestOONIBClient(unittest.TestCase): def setUp(self): - self.oonibclient = OONIBClient('http://127.0.0.1:8888') + host = '127.0.0.1' + port = 8888 + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + try: + s.connect((host, port)) + s.shutdown(2) + except Exception as ex: + self.skipTest("OONIB must be listening on port 8888 to run this test (tor_hidden_service: false)") + self.oonibclient = OONIBClient('http://%27+host+%27:%27+str(port))
@defer.inlineCallbacks def test_query(self):