##// END OF EJS Templates
Move configuration of Python test controllers into setup()
Thomas Kluyver -
Show More
@@ -127,13 +127,14 b' class PyTestController(TestController):'
127 #: str, Python command to execute in subprocess
127 #: str, Python command to execute in subprocess
128 pycmd = None
128 pycmd = None
129
129
130 def __init__(self, section):
130 def __init__(self, section, options):
131 """Create new test runner."""
131 """Create new test runner."""
132 TestController.__init__(self)
132 TestController.__init__(self)
133 self.section = section
133 self.section = section
134 # pycmd is put into cmd[2] in PyTestController.launch()
134 # pycmd is put into cmd[2] in PyTestController.launch()
135 self.cmd = [sys.executable, '-c', None, section]
135 self.cmd = [sys.executable, '-c', None, section]
136 self.pycmd = "from IPython.testing.iptest import run_iptest; run_iptest()"
136 self.pycmd = "from IPython.testing.iptest import run_iptest; run_iptest()"
137 self.options = options
137
138
138 def setup(self):
139 def setup(self):
139 ipydir = TemporaryDirectory()
140 ipydir = TemporaryDirectory()
@@ -145,6 +146,14 b' class PyTestController(TestController):'
145 # This means we won't get odd effects from our own matplotlib config
146 # This means we won't get odd effects from our own matplotlib config
146 self.env['MPLCONFIGDIR'] = workingdir.name
147 self.env['MPLCONFIGDIR'] = workingdir.name
147
148
149 # From options:
150 if self.options.xunit:
151 self.add_xunit()
152 if self.options.coverage:
153 self.add_coverage()
154 self.env['IPTEST_SUBPROC_STREAMS'] = self.options.subproc_streams
155 self.cmd.extend(self.options.extra_args)
156
148 @property
157 @property
149 def will_run(self):
158 def will_run(self):
150 try:
159 try:
@@ -273,28 +282,13 b' def prepare_controllers(options):'
273 test_sections['parallel'].enabled = False
282 test_sections['parallel'].enabled = False
274
283
275 c_js = [JSController(name) for name in js_testgroups]
284 c_js = [JSController(name) for name in js_testgroups]
276 c_py = [PyTestController(name) for name in py_testgroups]
285 c_py = [PyTestController(name, options) for name in py_testgroups]
277
278 configure_py_controllers(c_py, xunit=options.xunit,
279 coverage=options.coverage, subproc_streams=options.subproc_streams,
280 extra_args=options.extra_args)
281
286
282 controllers = c_py + c_js
287 controllers = c_py + c_js
283 to_run = [c for c in controllers if c.will_run]
288 to_run = [c for c in controllers if c.will_run]
284 not_run = [c for c in controllers if not c.will_run]
289 not_run = [c for c in controllers if not c.will_run]
285 return to_run, not_run
290 return to_run, not_run
286
291
287 def configure_py_controllers(controllers, xunit=False, coverage=False,
288 subproc_streams='capture', extra_args=()):
289 """Apply options for a collection of TestController objects."""
290 for controller in controllers:
291 if xunit:
292 controller.add_xunit()
293 if coverage:
294 controller.add_coverage()
295 controller.env['IPTEST_SUBPROC_STREAMS'] = subproc_streams
296 controller.cmd.extend(extra_args)
297
298 def do_run(controller, buffer_output=True):
292 def do_run(controller, buffer_output=True):
299 """Setup and run a test controller.
293 """Setup and run a test controller.
300
294
General Comments 0
You need to be logged in to leave comments. Login now