~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-11 06:15:33 UTC
  • mfrom: (5025.1.6 331095-malloc)
  • Revision ID: pqm@pqm.ubuntu.com-20100211061533-5glf4faoutadhql9
(mbp) avoid malloc(0)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
21
21
import os
22
22
import re
23
23
import socket
 
24
import stat
24
25
import sys
25
26
import time
26
27
 
27
28
from bzrlib import (
28
29
    errors,
29
 
    lazy_regex,
30
30
    osutils,
31
 
    symbol_versioning,
32
31
    tests,
33
32
    trace,
34
33
    win32utils,
35
34
    )
36
35
from bzrlib.tests import (
37
 
    features,
38
36
    file_utils,
39
37
    test__walkdirs_win32,
40
38
    )
41
 
from bzrlib.tests.scenarios import load_tests_apply_scenarios
42
39
 
43
40
 
44
41
class _UTF8DirReaderFeature(tests.Feature):
97
94
    return scenarios
98
95
 
99
96
 
100
 
load_tests = load_tests_apply_scenarios
 
97
def load_tests(basic_tests, module, loader):
 
98
    suite = loader.suiteClass()
 
99
    dir_reader_tests, remaining_tests = tests.split_suite_by_condition(
 
100
        basic_tests, tests.condition_isinstance(TestDirReader))
 
101
    tests.multiply_tests(dir_reader_tests, dir_reader_scenarios(), suite)
 
102
    suite.addTest(remaining_tests)
 
103
    return suite
101
104
 
102
105
 
103
106
class TestContainsWhitespace(tests.TestCase):
104
107
 
105
108
    def test_contains_whitespace(self):
106
 
        self.assertTrue(osutils.contains_whitespace(u' '))
107
 
        self.assertTrue(osutils.contains_whitespace(u'hello there'))
108
 
        self.assertTrue(osutils.contains_whitespace(u'hellothere\n'))
109
 
        self.assertTrue(osutils.contains_whitespace(u'hello\nthere'))
110
 
        self.assertTrue(osutils.contains_whitespace(u'hello\rthere'))
111
 
        self.assertTrue(osutils.contains_whitespace(u'hello\tthere'))
 
109
        self.failUnless(osutils.contains_whitespace(u' '))
 
110
        self.failUnless(osutils.contains_whitespace(u'hello there'))
 
111
        self.failUnless(osutils.contains_whitespace(u'hellothere\n'))
 
112
        self.failUnless(osutils.contains_whitespace(u'hello\nthere'))
 
113
        self.failUnless(osutils.contains_whitespace(u'hello\rthere'))
 
114
        self.failUnless(osutils.contains_whitespace(u'hello\tthere'))
112
115
 
113
116
        # \xa0 is "Non-breaking-space" which on some python locales thinks it
114
117
        # is whitespace, but we do not.
115
 
        self.assertFalse(osutils.contains_whitespace(u''))
116
 
        self.assertFalse(osutils.contains_whitespace(u'hellothere'))
117
 
        self.assertFalse(osutils.contains_whitespace(u'hello\xa0there'))
 
118
        self.failIf(osutils.contains_whitespace(u''))
 
119
        self.failIf(osutils.contains_whitespace(u'hellothere'))
 
120
        self.failIf(osutils.contains_whitespace(u'hello\xa0there'))
118
121
 
119
122
 
120
123
class TestRename(tests.TestCaseInTempDir):
134
137
        # This should work everywhere
135
138
        self.create_file('a', 'something in a\n')
136
139
        self._fancy_rename('a', 'b')
137
 
        self.assertPathDoesNotExist('a')
138
 
        self.assertPathExists('b')
 
140
        self.failIfExists('a')
 
141
        self.failUnlessExists('b')
139
142
        self.check_file_contents('b', 'something in a\n')
140
143
 
141
144
        self.create_file('a', 'new something in a\n')
148
151
        self.create_file('target', 'data in target\n')
149
152
        self.assertRaises((IOError, OSError), self._fancy_rename,
150
153
                          'missingsource', 'target')
151
 
        self.assertPathExists('target')
 
154
        self.failUnlessExists('target')
152
155
        self.check_file_contents('target', 'data in target\n')
153
156
 
154
157
    def test_fancy_rename_fails_if_source_and_target_missing(self):
159
162
        # Rename should be semi-atomic on all platforms
160
163
        self.create_file('a', 'something in a\n')
161
164
        osutils.rename('a', 'b')
162
 
        self.assertPathDoesNotExist('a')
163
 
        self.assertPathExists('b')
 
165
        self.failIfExists('a')
 
166
        self.failUnlessExists('b')
164
167
        self.check_file_contents('b', 'something in a\n')
165
168
 
166
169
        self.create_file('a', 'new something in a\n')
231
234
            self.assertFalse(osutils.is_inside_or_parent_of_any(dirs, fn))
232
235
 
233
236
 
234
 
class TestLstat(tests.TestCaseInTempDir):
235
 
 
236
 
    def test_lstat_matches_fstat(self):
237
 
        # On Windows, lstat and fstat don't always agree, primarily in the
238
 
        # 'st_ino' and 'st_dev' fields. So we force them to be '0' in our
239
 
        # custom implementation.
240
 
        if sys.platform == 'win32':
241
 
            # We only have special lstat/fstat if we have the extension.
242
 
            # Without it, we may end up re-reading content when we don't have
243
 
            # to, but otherwise it doesn't effect correctness.
244
 
            self.requireFeature(test__walkdirs_win32.win32_readdir_feature)
245
 
        f = open('test-file.txt', 'wb')
246
 
        self.addCleanup(f.close)
247
 
        f.write('some content\n')
248
 
        f.flush()
249
 
        self.assertEqualStat(osutils.fstat(f.fileno()),
250
 
                             osutils.lstat('test-file.txt'))
251
 
 
252
 
 
253
237
class TestRmTree(tests.TestCaseInTempDir):
254
238
 
255
239
    def test_rmtree(self):
267
251
 
268
252
        osutils.rmtree('dir')
269
253
 
270
 
        self.assertPathDoesNotExist('dir/file')
271
 
        self.assertPathDoesNotExist('dir')
 
254
        self.failIfExists('dir/file')
 
255
        self.failIfExists('dir')
272
256
 
273
257
 
274
258
class TestDeleteAny(tests.TestCaseInTempDir):
325
309
        self.assertEqual("/", osutils.kind_marker(osutils._directory_kind))
326
310
        self.assertEqual("@", osutils.kind_marker("symlink"))
327
311
        self.assertEqual("+", osutils.kind_marker("tree-reference"))
328
 
        self.assertEqual("", osutils.kind_marker("fifo"))
329
 
        self.assertEqual("", osutils.kind_marker("socket"))
330
 
        self.assertEqual("", osutils.kind_marker("unknown"))
 
312
        self.assertRaises(errors.BzrError, osutils.kind_marker, "unknown")
331
313
 
332
314
 
333
315
class TestUmask(tests.TestCaseInTempDir):
488
470
        f = file('MixedCaseName', 'w')
489
471
        f.close()
490
472
        actual = osutils.canonical_relpath(self.test_base_dir, 'mixedcasename')
491
 
        self.assertEqual('work/MixedCaseName', actual)
 
473
        self.failUnlessEqual('work/MixedCaseName', actual)
492
474
 
493
475
    def test_canonical_relpath_missing_tail(self):
494
476
        os.mkdir('MixedCaseParent')
495
477
        actual = osutils.canonical_relpath(self.test_base_dir,
496
478
                                           'mixedcaseparent/nochild')
497
 
        self.assertEqual('work/MixedCaseParent/nochild', actual)
 
479
        self.failUnlessEqual('work/MixedCaseParent/nochild', actual)
498
480
 
499
481
 
500
482
class Test_CICPCanonicalRelpath(tests.TestCaseWithTransport):
876
858
        self.assertEqual('//HOST/path', osutils._win98_abspath('//HOST/path'))
877
859
        # relative path
878
860
        cwd = osutils.getcwd().rstrip('/')
879
 
        drive = osutils.ntpath.splitdrive(cwd)[0]
 
861
        drive = osutils._nt_splitdrive(cwd)[0]
880
862
        self.assertEqual(cwd+'/path', osutils._win98_abspath('path'))
881
863
        self.assertEqual(drive+'/path', osutils._win98_abspath('/path'))
882
864
        # unicode path
924
906
        b.close()
925
907
 
926
908
        osutils._win32_rename('b', 'a')
927
 
        self.assertPathExists('a')
928
 
        self.assertPathDoesNotExist('b')
 
909
        self.failUnlessExists('a')
 
910
        self.failIfExists('b')
929
911
        self.assertFileEqual('baz\n', 'a')
930
912
 
931
913
    def test_rename_missing_file(self):
1079
1061
        self.assertExpectedBlocks(expected_dirblocks[1:], result)
1080
1062
 
1081
1063
    def test_walkdirs_os_error(self):
1082
 
        # <https://bugs.launchpad.net/bzr/+bug/338653>
 
1064
        # <https://bugs.edge.launchpad.net/bzr/+bug/338653>
1083
1065
        # Pyrex readdir didn't raise useful messages if it had an error
1084
1066
        # reading the directory
1085
1067
        if sys.platform == 'win32':
1086
1068
            raise tests.TestNotApplicable(
1087
1069
                "readdir IOError not tested on win32")
1088
 
        self.requireFeature(features.not_running_as_root)
1089
1070
        os.mkdir("test-unreadable")
1090
1071
        os.chmod("test-unreadable", 0000)
1091
1072
        # must chmod it back so that it can be removed
1099
1080
        # Ensure the message contains the file name
1100
1081
        self.assertContainsRe(str(e), "\./test-unreadable")
1101
1082
 
1102
 
 
1103
 
    def test_walkdirs_encoding_error(self):
1104
 
        # <https://bugs.launchpad.net/bzr/+bug/488519>
1105
 
        # walkdirs didn't raise a useful message when the filenames
1106
 
        # are not using the filesystem's encoding
1107
 
 
1108
 
        # require a bytestring based filesystem
1109
 
        self.requireFeature(tests.ByteStringNamedFilesystem)
1110
 
 
1111
 
        tree = [
1112
 
            '.bzr',
1113
 
            '0file',
1114
 
            '1dir/',
1115
 
            '1dir/0file',
1116
 
            '1dir/1dir/',
1117
 
            '1file'
1118
 
            ]
1119
 
 
1120
 
        self.build_tree(tree)
1121
 
 
1122
 
        # rename the 1file to a latin-1 filename
1123
 
        os.rename("./1file", "\xe8file")
1124
 
        if "\xe8file" not in os.listdir("."):
1125
 
            self.skip("Lack filesystem that preserves arbitrary bytes")
1126
 
 
1127
 
        self._save_platform_info()
1128
 
        win32utils.winver = None # Avoid the win32 detection code
1129
 
        osutils._fs_enc = 'UTF-8'
1130
 
 
1131
 
        # this should raise on error
1132
 
        def attempt():
1133
 
            for dirdetail, dirblock in osutils.walkdirs('.'):
1134
 
                pass
1135
 
 
1136
 
        self.assertRaises(errors.BadFilenameEncoding, attempt)
1137
 
 
1138
1083
    def test__walkdirs_utf8(self):
1139
1084
        tree = [
1140
1085
            '.bzr',
1614
1559
                          ('d', 'source/b', 'target/b'),
1615
1560
                          ('f', 'source/b/c', 'target/b/c'),
1616
1561
                         ], processed_files)
1617
 
        self.assertPathDoesNotExist('target')
 
1562
        self.failIfExists('target')
1618
1563
        if osutils.has_symlinks():
1619
1564
            self.assertEqual([('source/lnk', 'target/lnk')], processed_links)
1620
1565
 
1666
1611
        old = osutils.set_or_unset_env('BZR_TEST_ENV_VAR', None)
1667
1612
        self.assertEqual('foo', old)
1668
1613
        self.assertEqual(None, os.environ.get('BZR_TEST_ENV_VAR'))
1669
 
        self.assertFalse('BZR_TEST_ENV_VAR' in os.environ)
 
1614
        self.failIf('BZR_TEST_ENV_VAR' in os.environ)
1670
1615
 
1671
1616
 
1672
1617
class TestSizeShaFile(tests.TestCaseInTempDir):
1723
1668
 
1724
1669
class TestReCompile(tests.TestCase):
1725
1670
 
1726
 
    def _deprecated_re_compile_checked(self, *args, **kwargs):
1727
 
        return self.applyDeprecated(symbol_versioning.deprecated_in((2, 2, 0)),
1728
 
            osutils.re_compile_checked, *args, **kwargs)
1729
 
 
1730
1671
    def test_re_compile_checked(self):
1731
 
        r = self._deprecated_re_compile_checked(r'A*', re.IGNORECASE)
 
1672
        r = osutils.re_compile_checked(r'A*', re.IGNORECASE)
1732
1673
        self.assertTrue(r.match('aaaa'))
1733
1674
        self.assertTrue(r.match('aAaA'))
1734
1675
 
1735
1676
    def test_re_compile_checked_error(self):
1736
1677
        # like https://bugs.launchpad.net/bzr/+bug/251352
1737
 
 
1738
 
        # Due to possible test isolation error, re.compile is not lazy at
1739
 
        # this point. We re-install lazy compile.
1740
 
        lazy_regex.install_lazy_compile()
1741
1678
        err = self.assertRaises(
1742
1679
            errors.BzrCommandError,
1743
 
            self._deprecated_re_compile_checked, '*', re.IGNORECASE, 'test case')
 
1680
            osutils.re_compile_checked, '*', re.IGNORECASE, 'test case')
1744
1681
        self.assertEqual(
1745
 
            'Invalid regular expression in test case: '
1746
 
            '"*" nothing to repeat',
 
1682
            "Invalid regular expression in test case: '*': "
 
1683
            "nothing to repeat",
1747
1684
            str(err))
1748
1685
 
1749
1686
 
1750
1687
class TestDirReader(tests.TestCaseInTempDir):
1751
1688
 
1752
 
    scenarios = dir_reader_scenarios()
1753
 
 
1754
1689
    # Set by load_tests
1755
1690
    _dir_reader_class = None
1756
1691
    _native_to_unicode = None
1897
1832
        os.symlink(self.target, self.link)
1898
1833
 
1899
1834
    def test_os_readlink_link_encoding(self):
1900
 
        self.assertEquals(self.target,  os.readlink(self.link))
 
1835
        if sys.version_info < (2, 6):
 
1836
            self.assertRaises(UnicodeEncodeError, os.readlink, self.link)
 
1837
        else:
 
1838
            self.assertEquals(self.target,  os.readlink(self.link))
1901
1839
 
1902
1840
    def test_os_readlink_link_decoding(self):
1903
1841
        self.assertEquals(self.target.encode(osutils._fs_enc),
1915
1853
        self.assertIsInstance(concurrency, int)
1916
1854
 
1917
1855
    def test_local_concurrency_environment_variable(self):
1918
 
        self.overrideEnv('BZR_CONCURRENCY', '2')
 
1856
        os.environ['BZR_CONCURRENCY'] = '2'
1919
1857
        self.assertEqual(2, osutils.local_concurrency(use_cache=False))
1920
 
        self.overrideEnv('BZR_CONCURRENCY', '3')
 
1858
        os.environ['BZR_CONCURRENCY'] = '3'
1921
1859
        self.assertEqual(3, osutils.local_concurrency(use_cache=False))
1922
 
        self.overrideEnv('BZR_CONCURRENCY', 'foo')
 
1860
        os.environ['BZR_CONCURRENCY'] = 'foo'
1923
1861
        self.assertEqual(1, osutils.local_concurrency(use_cache=False))
1924
1862
 
1925
1863
    def test_option_concurrency(self):
1926
 
        self.overrideEnv('BZR_CONCURRENCY', '1')
 
1864
        os.environ['BZR_CONCURRENCY'] = '1'
1927
1865
        self.run_bzr('rocks --concurrency 42')
1928
 
        # Command line overrides environment variable
 
1866
        # Command line overrides envrionment variable
1929
1867
        self.assertEquals('42', os.environ['BZR_CONCURRENCY'])
1930
1868
        self.assertEquals(42, osutils.local_concurrency(use_cache=False))
1931
1869
 
1969
1907
 
1970
1908
class TestTerminalWidth(tests.TestCase):
1971
1909
 
1972
 
    def setUp(self):
1973
 
        tests.TestCase.setUp(self)
1974
 
        self._orig_terminal_size_state = osutils._terminal_size_state
1975
 
        self._orig_first_terminal_size = osutils._first_terminal_size
1976
 
        self.addCleanup(self.restore_osutils_globals)
1977
 
        osutils._terminal_size_state = 'no_data'
1978
 
        osutils._first_terminal_size = None
1979
 
 
1980
 
    def restore_osutils_globals(self):
1981
 
        osutils._terminal_size_state = self._orig_terminal_size_state
1982
 
        osutils._first_terminal_size = self._orig_first_terminal_size
1983
 
 
1984
1910
    def replace_stdout(self, new):
1985
1911
        self.overrideAttr(sys, 'stdout', new)
1986
1912
 
2001
1927
    def test_defaults_to_BZR_COLUMNS(self):
2002
1928
        # BZR_COLUMNS is set by the test framework
2003
1929
        self.assertNotEqual('12', os.environ['BZR_COLUMNS'])
2004
 
        self.overrideEnv('BZR_COLUMNS', '12')
 
1930
        os.environ['BZR_COLUMNS'] = '12'
2005
1931
        self.assertEqual(12, osutils.terminal_width())
2006
1932
 
2007
 
    def test_BZR_COLUMNS_0_no_limit(self):
2008
 
        self.overrideEnv('BZR_COLUMNS', '0')
2009
 
        self.assertEqual(None, osutils.terminal_width())
2010
 
 
2011
1933
    def test_falls_back_to_COLUMNS(self):
2012
 
        self.overrideEnv('BZR_COLUMNS', None)
 
1934
        del os.environ['BZR_COLUMNS']
2013
1935
        self.assertNotEqual('42', os.environ['COLUMNS'])
2014
1936
        self.set_fake_tty()
2015
 
        self.overrideEnv('COLUMNS', '42')
 
1937
        os.environ['COLUMNS'] = '42'
2016
1938
        self.assertEqual(42, osutils.terminal_width())
2017
1939
 
2018
1940
    def test_tty_default_without_columns(self):
2019
 
        self.overrideEnv('BZR_COLUMNS', None)
2020
 
        self.overrideEnv('COLUMNS', None)
 
1941
        del os.environ['BZR_COLUMNS']
 
1942
        del os.environ['COLUMNS']
2021
1943
 
2022
1944
        def terminal_size(w, h):
2023
1945
            return 42, 42
2030
1952
        self.assertEqual(42, osutils.terminal_width())
2031
1953
 
2032
1954
    def test_non_tty_default_without_columns(self):
2033
 
        self.overrideEnv('BZR_COLUMNS', None)
2034
 
        self.overrideEnv('COLUMNS', None)
 
1955
        del os.environ['BZR_COLUMNS']
 
1956
        del os.environ['COLUMNS']
2035
1957
        self.replace_stdout(None)
2036
1958
        self.assertEqual(None, osutils.terminal_width())
2037
1959
 
2047
1969
        else:
2048
1970
            self.overrideAttr(termios, 'TIOCGWINSZ')
2049
1971
            del termios.TIOCGWINSZ
2050
 
        self.overrideEnv('BZR_COLUMNS', None)
2051
 
        self.overrideEnv('COLUMNS', None)
 
1972
        del os.environ['BZR_COLUMNS']
 
1973
        del os.environ['COLUMNS']
2052
1974
        # Whatever the result is, if we don't raise an exception, it's ok.
2053
1975
        osutils.terminal_width()
2054
 
 
2055
 
 
2056
 
class TestCreationOps(tests.TestCaseInTempDir):
2057
 
    _test_needs_features = [features.chown_feature]
2058
 
 
2059
 
    def setUp(self):
2060
 
        tests.TestCaseInTempDir.setUp(self)
2061
 
        self.overrideAttr(os, 'chown', self._dummy_chown)
2062
 
 
2063
 
        # params set by call to _dummy_chown
2064
 
        self.path = self.uid = self.gid = None
2065
 
 
2066
 
    def _dummy_chown(self, path, uid, gid):
2067
 
        self.path, self.uid, self.gid = path, uid, gid
2068
 
 
2069
 
    def test_copy_ownership_from_path(self):
2070
 
        """copy_ownership_from_path test with specified src."""
2071
 
        ownsrc = '/'
2072
 
        f = open('test_file', 'wt')
2073
 
        osutils.copy_ownership_from_path('test_file', ownsrc)
2074
 
 
2075
 
        s = os.stat(ownsrc)
2076
 
        self.assertEquals(self.path, 'test_file')
2077
 
        self.assertEquals(self.uid, s.st_uid)
2078
 
        self.assertEquals(self.gid, s.st_gid)
2079
 
 
2080
 
    def test_copy_ownership_nonesrc(self):
2081
 
        """copy_ownership_from_path test with src=None."""
2082
 
        f = open('test_file', 'wt')
2083
 
        # should use parent dir for permissions
2084
 
        osutils.copy_ownership_from_path('test_file')
2085
 
 
2086
 
        s = os.stat('..')
2087
 
        self.assertEquals(self.path, 'test_file')
2088
 
        self.assertEquals(self.uid, s.st_uid)
2089
 
        self.assertEquals(self.gid, s.st_gid)
2090
 
 
2091
 
 
2092
 
class TestGetuserUnicode(tests.TestCase):
2093
 
 
2094
 
    def test_ascii_user(self):
2095
 
        self.overrideEnv('LOGNAME', 'jrandom')
2096
 
        self.assertEqual(u'jrandom', osutils.getuser_unicode())
2097
 
 
2098
 
    def test_unicode_user(self):
2099
 
        ue = osutils.get_user_encoding()
2100
 
        uni_val, env_val = tests.probe_unicode_in_user_encoding()
2101
 
        if uni_val is None:
2102
 
            raise tests.TestSkipped(
2103
 
                'Cannot find a unicode character that works in encoding %s'
2104
 
                % (osutils.get_user_encoding(),))
2105
 
        uni_username = u'jrandom' + uni_val
2106
 
        encoded_username = uni_username.encode(ue)
2107
 
        self.overrideEnv('LOGNAME', encoded_username)
2108
 
        self.assertEqual(uni_username, osutils.getuser_unicode())
2109
 
        self.overrideEnv('LOGNAME', u'jrandom\xb6'.encode(ue))
2110
 
        self.assertEqual(u'jrandom\xb6', osutils.getuser_unicode())
2111
 
 
2112
 
    def test_no_username_bug_660174(self):
2113
 
        self.requireFeature(features.win32_feature)
2114
 
        for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
2115
 
            self.overrideEnv(name, None)
2116
 
        self.assertEqual(u'UNKNOWN', osutils.getuser_unicode())
2117
 
 
2118
 
 
2119
 
class TestBackupNames(tests.TestCase):
2120
 
 
2121
 
    def setUp(self):
2122
 
        super(TestBackupNames, self).setUp()
2123
 
        self.backups = []
2124
 
 
2125
 
    def backup_exists(self, name):
2126
 
        return name in self.backups
2127
 
 
2128
 
    def available_backup_name(self, name):
2129
 
        backup_name = osutils.available_backup_name(name, self.backup_exists)
2130
 
        self.backups.append(backup_name)
2131
 
        return backup_name
2132
 
 
2133
 
    def assertBackupName(self, expected, name):
2134
 
        self.assertEqual(expected, self.available_backup_name(name))
2135
 
 
2136
 
    def test_empty(self):
2137
 
        self.assertBackupName('file.~1~', 'file')
2138
 
 
2139
 
    def test_existing(self):
2140
 
        self.available_backup_name('file')
2141
 
        self.available_backup_name('file')
2142
 
        self.assertBackupName('file.~3~', 'file')
2143
 
        # Empty slots are found, this is not a strict requirement and may be
2144
 
        # revisited if we test against all implementations.
2145
 
        self.backups.remove('file.~2~')
2146
 
        self.assertBackupName('file.~2~', 'file')
2147
 
 
2148
 
 
2149
 
class TestFindExecutableInPath(tests.TestCase):
2150
 
 
2151
 
    def test_windows(self):
2152
 
        if sys.platform != 'win32':
2153
 
            raise tests.TestSkipped('test requires win32')
2154
 
        self.assertTrue(osutils.find_executable_on_path('explorer') is not None)
2155
 
        self.assertTrue(
2156
 
            osutils.find_executable_on_path('explorer.exe') is not None)
2157
 
        self.assertTrue(
2158
 
            osutils.find_executable_on_path('EXPLORER.EXE') is not None)
2159
 
        self.assertTrue(
2160
 
            osutils.find_executable_on_path('THIS SHOULD NOT EXIST') is None)
2161
 
        self.assertTrue(osutils.find_executable_on_path('file.txt') is None)
2162
 
 
2163
 
    def test_other(self):
2164
 
        if sys.platform == 'win32':
2165
 
            raise tests.TestSkipped('test requires non-win32')
2166
 
        self.assertTrue(osutils.find_executable_on_path('sh') is not None)
2167
 
        self.assertTrue(
2168
 
            osutils.find_executable_on_path('THIS SHOULD NOT EXIST') is None)