cubicweb/devtools/qunit.py
changeset 11744 a6dc650bc230
parent 11742 def9b3757945
child 11745 f79dc500a4e7
equal deleted inserted replaced
11743:48d70d143dc1 11744:a6dc650bc230
    23 from subprocess import Popen, PIPE, STDOUT
    23 from subprocess import Popen, PIPE, STDOUT
    24 
    24 
    25 from six.moves.queue import Queue, Empty
    25 from six.moves.queue import Queue, Empty
    26 
    26 
    27 # imported by default to simplify further import statements
    27 # imported by default to simplify further import statements
    28 from logilab.common.testlib import with_tempdir, Tags
    28 from logilab.common.testlib import Tags
    29 import webtest.http
    29 import webtest.http
    30 
    30 
    31 import cubicweb
    31 import cubicweb
    32 from cubicweb.view import View
    32 from cubicweb.view import View
    33 from cubicweb.web.controller import Controller
    33 from cubicweb.web.controller import Controller
    34 from cubicweb.web.views.staticcontrollers import StaticFileController, STATIC_CONTROLLERS
    34 from cubicweb.web.views.staticcontrollers import StaticFileController, STATIC_CONTROLLERS
    35 from cubicweb.devtools import webtest as cwwebtest
    35 from cubicweb.devtools import webtest as cwwebtest
       
    36 from cubicweb.devtools.testlib import TemporaryDirectory
    36 
    37 
    37 
    38 
    38 class FirefoxHelper(object):
    39 class FirefoxHelper(object):
    39 
    40 
    40     def __init__(self, url=None):
    41     def __init__(self, url=None):
   107             test_file = args[0]
   108             test_file = args[0]
   108             if len(args) > 1:
   109             if len(args) > 1:
   109                 depends = args[1]
   110                 depends = args[1]
   110             else:
   111             else:
   111                 depends = ()
   112                 depends = ()
   112             for name, func, args in self._test_qunit(test_file, depends):
   113             with TemporaryDirectory():
   113                 with self.subTest(name=name):
   114                 for name, func, args in self._test_qunit(test_file, depends):
   114                     func(*args)
   115                     with self.subTest(name=name):
   115 
   116                         func(*args)
   116     @with_tempdir
   117 
   117     def _test_qunit(self, test_file, depends=(), timeout=10):
   118     def _test_qunit(self, test_file, depends=(), timeout=10):
   118         QUnitView.test_file = test_file
   119         QUnitView.test_file = test_file
   119         QUnitView.depends = depends
   120         QUnitView.depends = depends
   120 
   121 
   121         while not self.test_queue.empty():
   122         while not self.test_queue.empty():