mirror of
https://github.com/jupyter/notebook.git
synced 2025-04-24 14:20:54 +08:00
Work to address the review comments on Fernando's branch.
* Added comment about Magic(object) (r1224) * Moved InteractiveTB.set_mode from IPythonApp -> InteractiveShell (r1229) * Moved pylabtools.py to IPython/lib (r1229) * Cleaned up comments and copyrights in testing (r1233) * Added comment about ip.shell._ofind (r1237) * Removed "Bye." from quitter (r1240). * Refactored and removed :mod:`IPython.utils.genutils` and :mod:`IPython.utils.platutils`. These modules have been replaced by topical focused modules in :mod:`IPython.utils`. * Refactored tests in :mod:`IPython.utils.tests`. * Moved :func:`IPython.testing.tools.temp_pyfile` to :mod:`IPython.utils.io`. * Moved :func:`IPython.testing.tools.cmd2argv` to :func:`IPython.testing.tools.pycmd2argv` and documented the fact that this only works with Python based command line programs. * Created a new :func:`IPython.utils.path.get_ipython_module_path` to use in finding paths to IPython modules.
This commit is contained in:
parent
8965698c56
commit
e24997b0ba
@ -17,13 +17,19 @@ will change in the future.
|
||||
"""
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Module imports
|
||||
# Copyright (C) 2009 The IPython Development Team
|
||||
#
|
||||
# Distributed under the terms of the BSD License. The full license is in
|
||||
# the file COPYING, distributed as part of this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Imports
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Stdlib
|
||||
import os
|
||||
import os.path as path
|
||||
import platform
|
||||
import signal
|
||||
import sys
|
||||
import subprocess
|
||||
@ -50,11 +56,11 @@ import nose.plugins.builtin
|
||||
from nose.core import TestProgram
|
||||
|
||||
# Our own imports
|
||||
from IPython.core import release
|
||||
from IPython.utils import genutils
|
||||
from IPython.utils.platutils import find_cmd, FindCmdError
|
||||
from IPython.utils.path import get_ipython_module_path
|
||||
from IPython.utils.process import find_cmd, pycmd2argv
|
||||
from IPython.utils.sysinfo import sys_info
|
||||
|
||||
from IPython.testing import globalipapp
|
||||
from IPython.testing import tools
|
||||
from IPython.testing.plugin.ipdoctest import IPythonDoctest
|
||||
|
||||
pjoin = path.join
|
||||
@ -124,7 +130,7 @@ have['gobject'] = test_for('gobject')
|
||||
def report():
|
||||
"""Return a string with a summary report of test-related variables."""
|
||||
|
||||
out = [ genutils.sys_info() ]
|
||||
out = [ sys_info() ]
|
||||
|
||||
out.append('\nRunning from an installed IPython: %s\n' % INSTALLED)
|
||||
|
||||
@ -198,18 +204,12 @@ def make_exclude():
|
||||
if not have['objc']:
|
||||
exclusions.append(ipjoin('frontend', 'cocoa'))
|
||||
|
||||
if not sys.platform == 'win32':
|
||||
exclusions.append(ipjoin('utils', 'platutils_win32'))
|
||||
|
||||
# These have to be skipped on win32 because the use echo, rm, cd, etc.
|
||||
# See ticket https://bugs.launchpad.net/bugs/366982
|
||||
if sys.platform == 'win32':
|
||||
exclusions.append(ipjoin('testing', 'plugin', 'test_exampleip'))
|
||||
exclusions.append(ipjoin('testing', 'plugin', 'dtexample'))
|
||||
|
||||
if not os.name == 'posix':
|
||||
exclusions.append(ipjoin('utils', 'platutils_posix'))
|
||||
|
||||
if not have['pexpect']:
|
||||
exclusions.extend([ipjoin('scripts', 'irunner'),
|
||||
ipjoin('lib', 'irunner')])
|
||||
@ -256,19 +256,19 @@ class IPTester(object):
|
||||
p = os.path
|
||||
if runner == 'iptest':
|
||||
if INSTALLED:
|
||||
self.runner = tools.cmd2argv(
|
||||
p.abspath(find_cmd('iptest'))) + sys.argv[1:]
|
||||
iptest_app = get_ipython_module_path('IPython.testing.iptest')
|
||||
self.runner = pycmd2argv(iptest_app) + sys.argv[1:]
|
||||
else:
|
||||
# Find our own 'iptest' script OS-level entry point. Don't
|
||||
# look system-wide, so we are sure we pick up *this one*. And
|
||||
# pass through to subprocess call our own sys.argv
|
||||
ippath = p.abspath(p.join(p.dirname(__file__),'..','..'))
|
||||
script = p.join(ippath, 'iptest.py')
|
||||
self.runner = tools.cmd2argv(script) + sys.argv[1:]
|
||||
self.runner = pycmd2argv(script) + sys.argv[1:]
|
||||
|
||||
else:
|
||||
# For trial, it needs to be installed system-wide
|
||||
self.runner = tools.cmd2argv(p.abspath(find_cmd('trial')))
|
||||
self.runner = pycmd2argv(p.abspath(find_cmd('trial')))
|
||||
if params is None:
|
||||
params = []
|
||||
if isinstance(params, str):
|
||||
|
61
IPython/utils/tests/test_io.py
Normal file
61
IPython/utils/tests/test_io.py
Normal file
@ -0,0 +1,61 @@
|
||||
# encoding: utf-8
|
||||
"""Tests for io.py"""
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (C) 2008 The IPython Development Team
|
||||
#
|
||||
# Distributed under the terms of the BSD License. The full license is in
|
||||
# the file COPYING, distributed as part of this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Imports
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
import sys
|
||||
|
||||
from cStringIO import StringIO
|
||||
|
||||
import nose.tools as nt
|
||||
|
||||
from IPython.testing import decorators as dec
|
||||
from IPython.utils.io import Tee
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Tests
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_tee_simple():
|
||||
"Very simple check with stdout only"
|
||||
chan = StringIO()
|
||||
text = 'Hello'
|
||||
tee = Tee(chan, channel='stdout')
|
||||
print >> chan, text,
|
||||
nt.assert_equal(chan.getvalue(), text)
|
||||
|
||||
|
||||
class TeeTestCase(dec.ParametricTestCase):
|
||||
|
||||
def tchan(self, channel, check='close'):
|
||||
trap = StringIO()
|
||||
chan = StringIO()
|
||||
text = 'Hello'
|
||||
|
||||
std_ori = getattr(sys, channel)
|
||||
setattr(sys, channel, trap)
|
||||
|
||||
tee = Tee(chan, channel=channel)
|
||||
print >> chan, text,
|
||||
setattr(sys, channel, std_ori)
|
||||
trap_val = trap.getvalue()
|
||||
nt.assert_equals(chan.getvalue(), text)
|
||||
if check=='close':
|
||||
tee.close()
|
||||
else:
|
||||
del tee
|
||||
|
||||
def test(self):
|
||||
for chan in ['stdout', 'stderr']:
|
||||
for check in ['close', 'del']:
|
||||
yield self.tchan(chan, check)
|
2
setup.py
2
setup.py
@ -47,7 +47,7 @@ if os.path.exists('MANIFEST'): os.remove('MANIFEST')
|
||||
from distutils.core import setup
|
||||
|
||||
# Our own imports
|
||||
from IPython.utils.genutils import target_update
|
||||
from IPython.utils.path import target_update
|
||||
|
||||
from setupbase import (
|
||||
setup_args,
|
||||
|
Loading…
x
Reference in New Issue
Block a user