Show More
@@ -43,11 +43,10 b' KC = None' | |||||
43 | def start_new_kernel(argv=None): |
|
43 | def start_new_kernel(argv=None): | |
44 | """start a new kernel, and return its Manager and Client""" |
|
44 | """start a new kernel, and return its Manager and Client""" | |
45 | km = KernelManager() |
|
45 | km = KernelManager() | |
46 |
kwargs = dict(stdout=nose.ip |
|
46 | kwargs = dict(stdout=nose.iptest_stdstreams_fileno(), stderr=STDOUT) | |
47 | if argv: |
|
47 | if argv: | |
48 | kwargs['extra_arguments'] = argv |
|
48 | kwargs['extra_arguments'] = argv | |
49 | km.start_kernel(**kwargs) |
|
49 | km.start_kernel(**kwargs) | |
50 | nose.ipy_stream_capturer.ensure_started() |
|
|||
51 | kc = km.client() |
|
50 | kc = km.client() | |
52 | kc.start_channels() |
|
51 | kc.start_channels() | |
53 |
|
52 |
@@ -37,16 +37,15 b' class TestProcessLauncher(LocalProcessLauncher):' | |||||
37 | """subclass LocalProcessLauncher, to prevent extra sockets and threads being created on Windows""" |
|
37 | """subclass LocalProcessLauncher, to prevent extra sockets and threads being created on Windows""" | |
38 | def start(self): |
|
38 | def start(self): | |
39 | if self.state == 'before': |
|
39 | if self.state == 'before': | |
|
40 | # Store stdout & stderr to show with failing tests. | |||
|
41 | # This is defined in IPython.testing.iptest | |||
40 | self.process = Popen(self.args, |
|
42 | self.process = Popen(self.args, | |
41 |
stdout=nose.ip |
|
43 | stdout=nose.iptest_stdstreams_fileno(), stderr=STDOUT, | |
42 | env=os.environ, |
|
44 | env=os.environ, | |
43 | cwd=self.work_dir |
|
45 | cwd=self.work_dir | |
44 | ) |
|
46 | ) | |
45 | self.notify_start(self.process.pid) |
|
47 | self.notify_start(self.process.pid) | |
46 | self.poll = self.process.poll |
|
48 | self.poll = self.process.poll | |
47 | # Store stdout & stderr to show with failing tests. |
|
|||
48 | # This is defined in IPython.testing.iptest |
|
|||
49 | nose.ipy_stream_capturer.ensure_started() |
|
|||
50 | else: |
|
49 | else: | |
51 | s = 'The process was already started and has state: %r' % self.state |
|
50 | s = 'The process was already started and has state: %r' % self.state | |
52 | raise ProcessStateError(s) |
|
51 | raise ProcessStateError(s) |
@@ -407,14 +407,25 b' class SubprocessStreamCapturePlugin(Plugin):' | |||||
407 | def __init__(self): |
|
407 | def __init__(self): | |
408 | Plugin.__init__(self) |
|
408 | Plugin.__init__(self) | |
409 | self.stream_capturer = StreamCapturer() |
|
409 | self.stream_capturer = StreamCapturer() | |
|
410 | self.destination = os.environ.get('IPTEST_SUBPROC_STREAMS', 'capture') | |||
410 | # This is ugly, but distant parts of the test machinery need to be able |
|
411 | # This is ugly, but distant parts of the test machinery need to be able | |
411 | # to redirect streams, so we make the object globally accessible. |
|
412 | # to redirect streams, so we make the object globally accessible. | |
412 |
nose.ip |
|
413 | nose.iptest_stdstreams_fileno = self.get_write_fileno | |
|
414 | ||||
|
415 | def get_write_fileno(self): | |||
|
416 | if self.destination == 'capture': | |||
|
417 | self.stream_capturer.ensure_started() | |||
|
418 | return self.stream_capturer.writefd | |||
|
419 | elif self.destination == 'discard': | |||
|
420 | return os.open(os.devnull, os.O_WRONLY) | |||
|
421 | else: | |||
|
422 | return sys.__stdout__.fileno() | |||
413 |
|
423 | |||
414 | def configure(self, options, config): |
|
424 | def configure(self, options, config): | |
415 | Plugin.configure(self, options, config) |
|
425 | Plugin.configure(self, options, config) | |
416 | # Override nose trying to disable plugin. |
|
426 | # Override nose trying to disable plugin. | |
417 |
self. |
|
427 | if self.destination == 'capture': | |
|
428 | self.enabled = True | |||
418 |
|
429 | |||
419 | def startTest(self, test): |
|
430 | def startTest(self, test): | |
420 | # Reset log capture |
|
431 | # Reset log capture |
@@ -237,20 +237,23 b' def prepare_controllers(options):' | |||||
237 | c_py = [PyTestController(name) for name in py_testgroups] |
|
237 | c_py = [PyTestController(name) for name in py_testgroups] | |
238 |
|
238 | |||
239 | configure_py_controllers(c_py, xunit=options.xunit, |
|
239 | configure_py_controllers(c_py, xunit=options.xunit, | |
240 |
coverage=options.coverage, |
|
240 | coverage=options.coverage, subproc_streams=options.subproc_streams, | |
|
241 | extra_args=options.extra_args) | |||
241 |
|
242 | |||
242 | controllers = c_py + c_js |
|
243 | controllers = c_py + c_js | |
243 | to_run = [c for c in controllers if c.will_run] |
|
244 | to_run = [c for c in controllers if c.will_run] | |
244 | not_run = [c for c in controllers if not c.will_run] |
|
245 | not_run = [c for c in controllers if not c.will_run] | |
245 | return to_run, not_run |
|
246 | return to_run, not_run | |
246 |
|
247 | |||
247 |
def configure_py_controllers(controllers, xunit=False, coverage=False, |
|
248 | def configure_py_controllers(controllers, xunit=False, coverage=False, | |
|
249 | subproc_streams='capture', extra_args=()): | |||
248 | """Apply options for a collection of TestController objects.""" |
|
250 | """Apply options for a collection of TestController objects.""" | |
249 | for controller in controllers: |
|
251 | for controller in controllers: | |
250 | if xunit: |
|
252 | if xunit: | |
251 | controller.add_xunit() |
|
253 | controller.add_xunit() | |
252 | if coverage: |
|
254 | if coverage: | |
253 | controller.add_coverage() |
|
255 | controller.add_coverage() | |
|
256 | controller.env['IPTEST_SUBPROC_STREAMS'] = subproc_streams | |||
254 | controller.cmd.extend(extra_args) |
|
257 | controller.cmd.extend(extra_args) | |
255 |
|
258 | |||
256 | def do_run(controller): |
|
259 | def do_run(controller): | |
@@ -469,6 +472,9 b" argparser.add_argument('--xunit', action='store_true'," | |||||
469 | argparser.add_argument('--coverage', nargs='?', const=True, default=False, |
|
472 | argparser.add_argument('--coverage', nargs='?', const=True, default=False, | |
470 | help="Measure test coverage. Specify 'html' or " |
|
473 | help="Measure test coverage. Specify 'html' or " | |
471 | "'xml' to get reports.") |
|
474 | "'xml' to get reports.") | |
|
475 | argparser.add_argument('--subproc-streams', default='capture', | |||
|
476 | help="What to do with stdout/stderr from subprocesses. " | |||
|
477 | "'capture' (default), 'show' and 'discard' are the options.") | |||
472 |
|
478 | |||
473 | def default_options(): |
|
479 | def default_options(): | |
474 | """Get an argparse Namespace object with the default arguments, to pass to |
|
480 | """Get an argparse Namespace object with the default arguments, to pass to |
General Comments 0
You need to be logged in to leave comments.
Login now