Commit ac108329 authored by Łukasz Nowak's avatar Łukasz Nowak

Allow to test against real server.

parent 18a26c12
...@@ -160,13 +160,14 @@ class OnlineMixin: ...@@ -160,13 +160,14 @@ class OnlineMixin:
def setUp(self): def setUp(self):
self.host = "127.0.0.1" self.host = "127.0.0.1"
self.port = 8080 self.port = 8080
self.tree = tempfile.mkdtemp()
self._start_nc()
self.url = 'http://%s:%s/' % (self.host, self.port) self.url = 'http://%s:%s/' % (self.host, self.port)
self.shacache = os.environ.get('TEST_SHA_CACHE', self.shacache = os.environ.get('TEST_SHA_CACHE',
self.url + 'shacache') self.url + 'shacache')
self.shadir = os.environ.get('TEST_SHA_DIR', self.shadir = os.environ.get('TEST_SHA_DIR',
self.url + 'shadir') self.url + 'shadir')
if not 'TEST_SHA_CACHE' in os.environ and not 'TEST_SHA_DIR' in os.environ:
self.tree = tempfile.mkdtemp()
self._start_nc()
self.test_data = tempfile.TemporaryFile() self.test_data = tempfile.TemporaryFile()
self.test_string = str(random.random()) self.test_string = str(random.random())
self.test_data.write(self.test_string) self.test_data.write(self.test_string)
...@@ -175,14 +176,15 @@ class OnlineMixin: ...@@ -175,14 +176,15 @@ class OnlineMixin:
self.test_data.seek(0) self.test_data.seek(0)
def tearDown(self): def tearDown(self):
try: if not 'TEST_SHA_CACHE' in os.environ and not 'TEST_SHA_DIR' in os.environ:
httplib.HTTPConnection(self.host, self.port).request('KILL', '/') try:
except Exception: httplib.HTTPConnection(self.host, self.port).request('KILL', '/')
pass except Exception:
pass
if self.thread is not None:
self.thread.join() if self.thread is not None:
shutil.rmtree(self.tree) self.thread.join()
shutil.rmtree(self.tree)
class OnlineTest(OnlineMixin, unittest.TestCase): class OnlineTest(OnlineMixin, unittest.TestCase):
"""Online tests against real HTTP server""" """Online tests against real HTTP server"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment