예제 #1
0
def start_new_kernel(**kwargs):
    """start a new kernel, and return its Manager and Client
    
    Integrates with our output capturing for tests.
    """
    kwargs.update(dict(stdout=nose.iptest_stdstreams_fileno(), stderr=STDOUT))
    return manager.start_new_kernel(startup_timeout=STARTUP_TIMEOUT, **kwargs)
예제 #2
0
def start_new_kernel(**kwargs):
    """start a new kernel, and return its Manager and Client
    
    Integrates with our output capturing for tests.
    """
    kwargs.update(dict(stdout=nose.iptest_stdstreams_fileno(), stderr=STDOUT))
    return manager.start_new_kernel(startup_timeout=STARTUP_TIMEOUT, **kwargs)
예제 #3
0
def start_new_kernel(**kwargs):
    """start a new kernel, and return its Manager and Client

    Integrates with our output capturing for tests.
    """
    kwargs['stderr'] = STDOUT
    try:
        kwargs['stdout'] = nose.iptest_stdstreams_fileno()
    except AttributeError:
        pass
    return manager.start_new_kernel(startup_timeout=STARTUP_TIMEOUT, **kwargs)
예제 #4
0
def start_new_kernel(**kwargs):
    """start a new kernel, and return its Manager and Client

    Integrates with our output capturing for tests.
    """
    try:
        stdout = nose.iptest_stdstreams_fileno()
    except AttributeError:
        stdout = open(os.devnull)
    kwargs.update(dict(stdout=stdout, stderr=STDOUT))
    return manager.start_new_kernel(startup_timeout=STARTUP_TIMEOUT, **kwargs)
예제 #5
0
파일: utils.py 프로젝트: jdetle/ipykernel
def start_new_kernel(**kwargs):
    """start a new kernel, and return its Manager and Client

    Integrates with our output capturing for tests.
    """
    try:
        stdout = nose.iptest_stdstreams_fileno()
    except AttributeError:
        stdout = open(os.devnull)
    kwargs.update(dict(stdout=stdout, stderr=STDOUT))
    return manager.start_new_kernel(startup_timeout=STARTUP_TIMEOUT, **kwargs)
예제 #6
0
파일: __init__.py 프로젝트: tomspur/ipython
 def start(self):
     if self.state == "before":
         # Store stdout & stderr to show with failing tests.
         # This is defined in IPython.testing.iptest
         self.process = Popen(
             self.args, stdout=nose.iptest_stdstreams_fileno(), stderr=STDOUT, env=os.environ, cwd=self.work_dir
         )
         self.notify_start(self.process.pid)
         self.poll = self.process.poll
     else:
         s = "The process was already started and has state: %r" % self.state
         raise ProcessStateError(s)
예제 #7
0
def new_kernel(argv=None):
    """Context manager for a new kernel in a subprocess

    Should only be used for tests where the kernel must not be re-used.

    Returns
    -------
    kernel_client: connected KernelClient instance
    """
    kwargs = dict(stdout=nose.iptest_stdstreams_fileno(), stderr=STDOUT, startup_timeout=STARTUP_TIMEOUT)
    if argv is not None:
        kwargs["extra_arguments"] = argv
    return manager.run_kernel(**kwargs)
예제 #8
0
 def start(self):
     if self.state == 'before':
         # Store stdout & stderr to show with failing tests.
         # This is defined in IPython.testing.iptest
         self.process = Popen(self.args,
                              stdout=nose.iptest_stdstreams_fileno(),
                              stderr=STDOUT,
                              env=os.environ,
                              cwd=self.work_dir)
         self.notify_start(self.process.pid)
         self.poll = self.process.poll
     else:
         s = 'The process was already started and has state: %r' % self.state
         raise ProcessStateError(s)
예제 #9
0
파일: utils.py 프로젝트: pyarnold/ipython
def start_new_kernel(argv=None):
    """start a new kernel, and return its Manager and Client"""
    km = KernelManager()
    kwargs = dict(stdout=nose.iptest_stdstreams_fileno(), stderr=STDOUT)
    if argv:
        kwargs['extra_arguments'] = argv
    km.start_kernel(**kwargs)
    kc = km.client()
    kc.start_channels()

    msg_id = kc.kernel_info()
    kc.get_shell_msg(block=True, timeout=STARTUP_TIMEOUT)
    flush_channels(kc)
    return km, kc
예제 #10
0
def new_kernel(argv=None):
    """Context manager for a new kernel in a subprocess
    
    Should only be used for tests where the kernel must not be re-used.
    
    Returns
    -------
    kernel_client: connected KernelClient instance
    """
    kwargs = dict(stdout=nose.iptest_stdstreams_fileno(), stderr=STDOUT,
                  startup_timeout=STARTUP_TIMEOUT)
    if argv is not None:
        kwargs['extra_arguments'] = argv
    return manager.run_kernel(**kwargs)
예제 #11
0
파일: utils.py 프로젝트: vincentk/ipython
def start_new_kernel(argv=None):
    """start a new kernel, and return its Manager and Client"""
    km = KernelManager()
    kwargs = dict(stdout=nose.iptest_stdstreams_fileno(), stderr=STDOUT)
    if argv:
        kwargs['extra_arguments'] = argv
    km.start_kernel(**kwargs)
    kc = km.client()
    kc.start_channels()

    msg_id = kc.kernel_info()
    kc.get_shell_msg(block=True, timeout=STARTUP_TIMEOUT)
    flush_channels(kc)
    return km, kc
예제 #12
0
 def setup_class(cls):
     cls.ipython_dir = TemporaryDirectory()
     cls.notebook_dir = TemporaryDirectory()
     notebook_args = [
         sys.executable, '-c',
         'from IPython.html.notebookapp import launch_new_instance; launch_new_instance()',
         '--port=%d' % cls.port,
         '--no-browser',
         '--ipython-dir=%s' % cls.ipython_dir.name,
         '--notebook-dir=%s' % cls.notebook_dir.name,
     ]
     cls.notebook = Popen(notebook_args,
         stdout=nose.iptest_stdstreams_fileno(),
         stderr=STDOUT,
     )
     cls.wait_until_alive()
예제 #13
0
def new_kernel(argv=None):
    """Context manager for a new kernel in a subprocess

    Should only be used for tests where the kernel must not be re-used.

    Returns
    -------
    kernel_client: connected KernelClient instance
    """
    kwargs = {'stderr': STDOUT}
    try:
        kwargs['stdout'] = nose.iptest_stdstreams_fileno()
    except AttributeError:
        pass
    if argv is not None:
        kwargs['extra_arguments'] = argv
    return manager.run_kernel(**kwargs)
예제 #14
0
 def setup_class(cls):
     cls.ipython_dir = TemporaryDirectory()
     cls.notebook_dir = TemporaryDirectory()
     notebook_args = [
         sys.executable, '-c',
         'from IPython.html.notebookapp import launch_new_instance; launch_new_instance()',
         '--port=%d' % cls.port,
         '--port-retries=0',  # Don't try any other ports
         '--no-browser',
         '--ipython-dir=%s' % cls.ipython_dir.name,
         '--notebook-dir=%s' % cls.notebook_dir.name,
     ]
     cls.notebook = Popen(notebook_args,
         stdout=nose.iptest_stdstreams_fileno(),
         stderr=STDOUT,
     )
     cls.wait_until_alive()