[devtools] make httptest module importable under py3k
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 06 Oct 2015 11:19:37 +0200
changeset 10781 e2ab20561932
parent 10780 a96ed0acc556
child 10782 65bb683d2a51
[devtools] make httptest module importable under py3k
devtools/httptest.py
--- a/devtools/httptest.py	Tue Oct 06 11:16:27 2015 +0200
+++ b/devtools/httptest.py	Tue Oct 06 11:19:37 2015 +0200
@@ -29,9 +29,7 @@
 from six.moves import range, http_client
 from six.moves.urllib.parse import urlparse
 
-from twisted.internet import reactor, error
 
-from cubicweb.etwist.server import run
 from cubicweb.devtools.testlib import CubicWebTC
 from cubicweb.devtools import ApptestConfiguration
 
@@ -92,6 +90,8 @@
     configcls = CubicWebServerConfig
 
     def start_server(self):
+        from twisted.internet import reactor
+        from cubicweb.etwist.server import run
         # use a semaphore to avoid starting test while the http server isn't
         # fully initilialized
         semaphore = threading.Semaphore(0)
@@ -119,6 +119,7 @@
 
     def stop_server(self, timeout=15):
         """Stop the webserver, waiting for the thread to return"""
+        from twisted.internet import reactor
         if self._web_test_cnx is None:
             self.web_logout()
             self._web_test_cnx.close()
@@ -177,6 +178,7 @@
         self.start_server()
 
     def tearDown(self):
+        from twisted.internet import error
         try:
             self.stop_server()
         except error.ReactorNotRunning as err: