From a42db8cd791db3d0e97845787b655fedb0eb8338 2010-01-13 01:19:39 From: Fernando Perez Date: 2010-01-13 01:19:39 Subject: [PATCH] More win32 fixes and refinements to test suite. --- diff --git a/IPython/utils/platutils.py b/IPython/utils/platutils.py index 2c3e52a..8dce2fc 100644 --- a/IPython/utils/platutils.py +++ b/IPython/utils/platutils.py @@ -79,7 +79,7 @@ def find_cmd(cmd): return sys.executable try: path = _platutils.find_cmd(cmd) - except: + except OSError: raise FindCmdError('command could not be found: %s' % cmd) # which returns empty if not found if path == '': diff --git a/IPython/utils/tests/test_platutils.py b/IPython/utils/tests/test_platutils.py index 4446789..9d83eee 100644 --- a/IPython/utils/tests/test_platutils.py +++ b/IPython/utils/tests/test_platutils.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # encoding: utf-8 """ Tests for platutils.py @@ -31,29 +30,43 @@ def test_find_cmd_python(): """Make sure we find sys.exectable for python.""" nt.assert_equals(find_cmd('python'), sys.executable) + @dec.skip_win32 -def test_find_cmd(): +def test_find_cmd_ls(): """Make sure we can find the full path to ls.""" path = find_cmd('ls') nt.assert_true(path.endswith('ls')) -@dec.skip_if_not_win32 -def test_find_cmd(): + +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(): """Try to find pythonw on Windows.""" path = find_cmd('pythonw') nt.assert_true(path.endswith('pythonw.exe')) + +@dec.onlyif(lambda : sys.platform != 'win32' or has_pywin32(), + "This test runs on posix or in win32 with win32api installed") 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') + @dec.skip_if_not_win32 def test_get_long_path_name_win32(): p = get_long_path_name('c:\\docume~1') nt.assert_equals(p,u'c:\\Documents and Settings') - + + @dec.skip_win32 def test_get_long_path_name(): p = get_long_path_name('/usr/local') nt.assert_equals(p,'/usr/local') -