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

Allow to test against real server.

parent 18a26c12
......@@ -160,13 +160,14 @@ class OnlineMixin:
def setUp(self):
self.host = "127.0.0.1"
self.port = 8080
self.tree = tempfile.mkdtemp()
self._start_nc()
self.url = 'http://%s:%s/' % (self.host, self.port)
self.shacache = os.environ.get('TEST_SHA_CACHE',
self.url + 'shacache')
self.shadir = os.environ.get('TEST_SHA_DIR',
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_string = str(random.random())
self.test_data.write(self.test_string)
......@@ -175,14 +176,15 @@ class OnlineMixin:
self.test_data.seek(0)
def tearDown(self):
try:
httplib.HTTPConnection(self.host, self.port).request('KILL', '/')
except Exception:
pass
if self.thread is not None:
self.thread.join()
shutil.rmtree(self.tree)
if not 'TEST_SHA_CACHE' in os.environ and not 'TEST_SHA_DIR' in os.environ:
try:
httplib.HTTPConnection(self.host, self.port).request('KILL', '/')
except Exception:
pass
if self.thread is not None:
self.thread.join()
shutil.rmtree(self.tree)
class OnlineTest(OnlineMixin, unittest.TestCase):
"""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