test_process.py
68 lines
| 2.0 KiB
| text/x-python
|
PythonLexer
Brian Granger
|
r1976 | # encoding: utf-8 | ||
""" | ||||
Tests for platutils.py | ||||
""" | ||||
#----------------------------------------------------------------------------- | ||||
# Copyright (C) 2008-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 | ||||
#----------------------------------------------------------------------------- | ||||
import sys | ||||
import nose.tools as nt | ||||
Fernando Perez
|
r2650 | from IPython.utils.process import find_cmd, FindCmdError, arg_split | ||
Brian Granger
|
r1976 | from IPython.testing import decorators as dec | ||
#----------------------------------------------------------------------------- | ||||
# Tests | ||||
#----------------------------------------------------------------------------- | ||||
def test_find_cmd_python(): | ||||
"""Make sure we find sys.exectable for python.""" | ||||
nt.assert_equals(find_cmd('python'), sys.executable) | ||||
Fernando Perez
|
r2453 | |||
Brian Granger
|
r1976 | @dec.skip_win32 | ||
Fernando Perez
|
r2453 | def test_find_cmd_ls(): | ||
Brian Granger
|
r1976 | """Make sure we can find the full path to ls.""" | ||
path = find_cmd('ls') | ||||
nt.assert_true(path.endswith('ls')) | ||||
Fernando Perez
|
r2453 | |||
def has_pywin32(): | ||||
try: | ||||
import win32api | ||||
except ImportError: | ||||
return False | ||||
return True | ||||
@dec.onlyif(has_pywin32, "This test requires win32api to run") | ||||
def test_find_cmd_pythonw(): | ||||
Brian Granger
|
r1976 | """Try to find pythonw on Windows.""" | ||
path = find_cmd('pythonw') | ||||
nt.assert_true(path.endswith('pythonw.exe')) | ||||
Fernando Perez
|
r2453 | |||
@dec.onlyif(lambda : sys.platform != 'win32' or has_pywin32(), | ||||
"This test runs on posix or in win32 with win32api installed") | ||||
Brian Granger
|
r1976 | def test_find_cmd_fail(): | ||
"""Make sure that FindCmdError is raised if we can't find the cmd.""" | ||||
nt.assert_raises(FindCmdError,find_cmd,'asdfasdf') | ||||
Administrator
|
r1986 | |||
Fernando Perez
|
r2453 | |||
Fernando Perez
|
r2650 | def test_arg_split(): | ||
"""Ensure that argument lines are correctly split like in a shell.""" | ||||
tests = [['hi', ['hi']], | ||||
[u'hi', [u'hi']], | ||||
] | ||||
for argstr, argv in tests: | ||||
nt.assert_equal(arg_split(argstr), argv) | ||||