##// END OF EJS Templates
Simplify StreamCapturer for subprocess testing...
Simplify StreamCapturer for subprocess testing Rather than using a transient pipe for each subprocess started, the StreamCapturer now makes a single pipe, and subprocesses redirect their output to it. So long as this works on Windows (I've done brief testing, and os.pipe() seems to be functional), this will hopefully make this much more robust. The recent failures in ShiningPanda on IPython.parallel have been caused by StreamCapturer.

File last commit:

r12400:695d4711
r13405:4ad2c011
Show More
test_launcher.py
58 lines | 2.0 KiB | text/x-python | PythonLexer
"""Tests for kernel utility functions
Authors
-------
* MinRK
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2011, the IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
# Third-party imports
import nose.tools as nt
# Our own imports
from IPython.kernel.launcher import swallow_argv
#-----------------------------------------------------------------------------
# Classes and functions
#-----------------------------------------------------------------------------
def test_swallow_argv():
tests = [
# expected , argv , aliases, flags
(['-a', '5'], ['-a', '5'], None, None),
(['5'], ['-a', '5'], None, ['a']),
([], ['-a', '5'], ['a'], None),
([], ['-a', '5'], ['a'], ['a']),
([], ['--foo'], None, ['foo']),
([], ['--foo'], ['foobar'], []),
([], ['--foo', '5'], ['foo'], []),
([], ['--foo=5'], ['foo'], []),
(['--foo=5'], ['--foo=5'], [], ['foo']),
(['5'], ['--foo', '5'], [], ['foo']),
(['bar'], ['--foo', '5', 'bar'], ['foo'], ['foo']),
(['bar'], ['--foo=5', 'bar'], ['foo'], ['foo']),
(['5','bar'], ['--foo', '5', 'bar'], None, ['foo']),
(['bar'], ['--foo', '5', 'bar'], ['foo'], None),
(['bar'], ['--foo=5', 'bar'], ['foo'], None),
]
for expected, argv, aliases, flags in tests:
stripped = swallow_argv(argv, aliases=aliases, flags=flags)
message = '\n'.join(['',
"argv: %r" % argv,
"aliases: %r" % aliases,
"flags : %r" % flags,
"expected : %r" % expected,
"returned : %r" % stripped,
])
nt.assert_equal(expected, stripped, message)