Show More
@@ -79,7 +79,7 b' def find_cmd(cmd):' | |||||
79 | return sys.executable |
|
79 | return sys.executable | |
80 | try: |
|
80 | try: | |
81 | path = _platutils.find_cmd(cmd) |
|
81 | path = _platutils.find_cmd(cmd) | |
82 | except: |
|
82 | except OSError: | |
83 | raise FindCmdError('command could not be found: %s' % cmd) |
|
83 | raise FindCmdError('command could not be found: %s' % cmd) | |
84 | # which returns empty if not found |
|
84 | # which returns empty if not found | |
85 | if path == '': |
|
85 | if path == '': |
@@ -1,4 +1,3 b'' | |||||
1 | #!/usr/bin/env python |
|
|||
2 |
|
|
1 | # encoding: utf-8 | |
3 | """ |
|
2 | """ | |
4 | Tests for platutils.py |
|
3 | Tests for platutils.py | |
@@ -31,29 +30,43 b' def test_find_cmd_python():' | |||||
31 | """Make sure we find sys.exectable for python.""" |
|
30 | """Make sure we find sys.exectable for python.""" | |
32 | nt.assert_equals(find_cmd('python'), sys.executable) |
|
31 | nt.assert_equals(find_cmd('python'), sys.executable) | |
33 |
|
32 | |||
|
33 | ||||
34 | @dec.skip_win32 |
|
34 | @dec.skip_win32 | |
35 | def test_find_cmd(): |
|
35 | def test_find_cmd_ls(): | |
36 | """Make sure we can find the full path to ls.""" |
|
36 | """Make sure we can find the full path to ls.""" | |
37 | path = find_cmd('ls') |
|
37 | path = find_cmd('ls') | |
38 | nt.assert_true(path.endswith('ls')) |
|
38 | nt.assert_true(path.endswith('ls')) | |
39 |
|
39 | |||
40 | @dec.skip_if_not_win32 |
|
40 | ||
41 | def test_find_cmd(): |
|
41 | def has_pywin32(): | |
|
42 | try: | |||
|
43 | import win32api | |||
|
44 | except ImportError: | |||
|
45 | return False | |||
|
46 | return True | |||
|
47 | ||||
|
48 | ||||
|
49 | @dec.onlyif(has_pywin32, "This test requires win32api to run") | |||
|
50 | def test_find_cmd_pythonw(): | |||
42 | """Try to find pythonw on Windows.""" |
|
51 | """Try to find pythonw on Windows.""" | |
43 | path = find_cmd('pythonw') |
|
52 | path = find_cmd('pythonw') | |
44 | nt.assert_true(path.endswith('pythonw.exe')) |
|
53 | nt.assert_true(path.endswith('pythonw.exe')) | |
45 |
|
54 | |||
|
55 | ||||
|
56 | @dec.onlyif(lambda : sys.platform != 'win32' or has_pywin32(), | |||
|
57 | "This test runs on posix or in win32 with win32api installed") | |||
46 | def test_find_cmd_fail(): |
|
58 | def test_find_cmd_fail(): | |
47 | """Make sure that FindCmdError is raised if we can't find the cmd.""" |
|
59 | """Make sure that FindCmdError is raised if we can't find the cmd.""" | |
48 | nt.assert_raises(FindCmdError,find_cmd,'asdfasdf') |
|
60 | nt.assert_raises(FindCmdError,find_cmd,'asdfasdf') | |
49 |
|
61 | |||
|
62 | ||||
50 | @dec.skip_if_not_win32 |
|
63 | @dec.skip_if_not_win32 | |
51 | def test_get_long_path_name_win32(): |
|
64 | def test_get_long_path_name_win32(): | |
52 | p = get_long_path_name('c:\\docume~1') |
|
65 | p = get_long_path_name('c:\\docume~1') | |
53 | nt.assert_equals(p,u'c:\\Documents and Settings') |
|
66 | nt.assert_equals(p,u'c:\\Documents and Settings') | |
54 |
|
67 | |||
|
68 | ||||
55 | @dec.skip_win32 |
|
69 | @dec.skip_win32 | |
56 | def test_get_long_path_name(): |
|
70 | def test_get_long_path_name(): | |
57 | p = get_long_path_name('/usr/local') |
|
71 | p = get_long_path_name('/usr/local') | |
58 | nt.assert_equals(p,'/usr/local') |
|
72 | nt.assert_equals(p,'/usr/local') | |
59 |
|
General Comments 0
You need to be logged in to leave comments.
Login now