~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: 2011-08-17 18:13:57 UTC
  • mfrom: (5268.7.29 transport-segments)
  • Revision ID: pqm@pqm.ubuntu.com-20110817181357-y5q5eth1hk8bl3om
(jelmer) Allow specifying the colocated branch to use in the branch URL,
 and retrieving the branch name using ControlDir._get_selected_branch.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2016 Canonical Ltd
 
1
# Copyright (C) 2005-2011 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
20
20
import errno
21
21
import os
22
22
import re
23
 
import select
24
23
import socket
25
24
import sys
26
 
import tempfile
27
25
import time
28
26
 
29
27
from bzrlib import (
180
178
        # we can't use failUnlessExists on case-insensitive filesystem
181
179
        # so try to check shape of the tree
182
180
        shape = sorted(os.listdir('.'))
183
 
        self.assertEqual(['A', 'B'], shape)
184
 
 
185
 
    def test_rename_exception(self):
186
 
        try:
187
 
            osutils.rename('nonexistent_path', 'different_nonexistent_path')
188
 
        except OSError, e:
189
 
            self.assertEqual(e.old_filename, 'nonexistent_path')
190
 
            self.assertEqual(e.new_filename, 'different_nonexistent_path')
191
 
            self.assertTrue('nonexistent_path' in e.strerror)
192
 
            self.assertTrue('different_nonexistent_path' in e.strerror)
 
181
        self.assertEquals(['A', 'B'], shape)
193
182
 
194
183
 
195
184
class TestRandChars(tests.TestCase):
222
211
                         (['src'], SRC_FOO_C),
223
212
                         (['src'], 'src'),
224
213
                         ]:
225
 
            self.assertTrue(osutils.is_inside_any(dirs, fn))
 
214
            self.assert_(osutils.is_inside_any(dirs, fn))
226
215
        for dirs, fn in [(['src'], 'srccontrol'),
227
216
                         (['src'], 'srccontrol/foo')]:
228
217
            self.assertFalse(osutils.is_inside_any(dirs, fn))
234
223
                         (['src/bar.c', 'bla/foo.c'], 'src'),
235
224
                         (['src'], 'src'),
236
225
                         ]:
237
 
            self.assertTrue(osutils.is_inside_or_parent_of_any(dirs, fn))
 
226
            self.assert_(osutils.is_inside_or_parent_of_any(dirs, fn))
238
227
 
239
228
        for dirs, fn in [(['src'], 'srccontrol'),
240
229
                         (['srccontrol/foo.c'], 'src'),
298
287
 
299
288
    def test_file_kind(self):
300
289
        self.build_tree(['file', 'dir/'])
301
 
        self.assertEqual('file', osutils.file_kind('file'))
302
 
        self.assertEqual('directory', osutils.file_kind('dir/'))
 
290
        self.assertEquals('file', osutils.file_kind('file'))
 
291
        self.assertEquals('directory', osutils.file_kind('dir/'))
303
292
        if osutils.has_symlinks():
304
293
            os.symlink('symlink', 'symlink')
305
 
            self.assertEqual('symlink', osutils.file_kind('symlink'))
 
294
            self.assertEquals('symlink', osutils.file_kind('symlink'))
306
295
 
307
296
        # TODO: jam 20060529 Test a block device
308
297
        try:
311
300
            if e.errno not in (errno.ENOENT,):
312
301
                raise
313
302
        else:
314
 
            self.assertEqual('chardev', osutils.file_kind('/dev/null'))
 
303
            self.assertEquals('chardev', osutils.file_kind('/dev/null'))
315
304
 
316
305
        mkfifo = getattr(os, 'mkfifo', None)
317
306
        if mkfifo:
318
307
            mkfifo('fifo')
319
308
            try:
320
 
                self.assertEqual('fifo', osutils.file_kind('fifo'))
 
309
                self.assertEquals('fifo', osutils.file_kind('fifo'))
321
310
            finally:
322
311
                os.remove('fifo')
323
312
 
326
315
            s = socket.socket(AF_UNIX)
327
316
            s.bind('socket')
328
317
            try:
329
 
                self.assertEqual('socket', osutils.file_kind('socket'))
 
318
                self.assertEquals('socket', osutils.file_kind('socket'))
330
319
            finally:
331
320
                os.remove('socket')
332
321
 
437
426
        self.assertTrue(-eighteen_hours < offset < eighteen_hours)
438
427
 
439
428
 
440
 
class TestFdatasync(tests.TestCaseInTempDir):
441
 
 
442
 
    def do_fdatasync(self):
443
 
        f = tempfile.NamedTemporaryFile()
444
 
        osutils.fdatasync(f.fileno())
445
 
        f.close()
446
 
 
447
 
    @staticmethod
448
 
    def raise_eopnotsupp(*args, **kwargs):
449
 
        raise IOError(errno.EOPNOTSUPP, os.strerror(errno.EOPNOTSUPP))
450
 
 
451
 
    @staticmethod
452
 
    def raise_enotsup(*args, **kwargs):
453
 
        raise IOError(errno.ENOTSUP, os.strerror(errno.ENOTSUP))
454
 
 
455
 
    def test_fdatasync_handles_system_function(self):
456
 
        self.overrideAttr(os, "fdatasync")
457
 
        self.do_fdatasync()
458
 
 
459
 
    def test_fdatasync_handles_no_fdatasync_no_fsync(self):
460
 
        self.overrideAttr(os, "fdatasync")
461
 
        self.overrideAttr(os, "fsync")
462
 
        self.do_fdatasync()
463
 
 
464
 
    def test_fdatasync_handles_no_EOPNOTSUPP(self):
465
 
        self.overrideAttr(errno, "EOPNOTSUPP")
466
 
        self.do_fdatasync()
467
 
 
468
 
    def test_fdatasync_catches_ENOTSUP(self):
469
 
        enotsup = getattr(errno, "ENOTSUP", None)
470
 
        if enotsup is None:
471
 
            raise tests.TestNotApplicable("No ENOTSUP on this platform")
472
 
        self.overrideAttr(os, "fdatasync", self.raise_enotsup)
473
 
        self.do_fdatasync()
474
 
 
475
 
    def test_fdatasync_catches_EOPNOTSUPP(self):
476
 
        enotsup = getattr(errno, "EOPNOTSUPP", None)
477
 
        if enotsup is None:
478
 
            raise tests.TestNotApplicable("No EOPNOTSUPP on this platform")
479
 
        self.overrideAttr(os, "fdatasync", self.raise_eopnotsupp)
480
 
        self.do_fdatasync()
481
 
 
482
 
 
483
429
class TestLinks(tests.TestCaseInTempDir):
484
430
 
485
431
    def test_dereference_path(self):
598
544
    """Test pumpfile method."""
599
545
 
600
546
    def setUp(self):
601
 
        super(TestPumpFile, self).setUp()
 
547
        tests.TestCase.setUp(self)
602
548
        # create a test datablock
603
549
        self.block_size = 512
604
550
        pattern = '0123456789ABCDEF'
872
818
        self.assertEqual(None, osutils.safe_file_id(None))
873
819
 
874
820
 
875
 
class TestSendAll(tests.TestCase):
876
 
 
877
 
    def test_send_with_disconnected_socket(self):
878
 
        class DisconnectedSocket(object):
879
 
            def __init__(self, err):
880
 
                self.err = err
881
 
            def send(self, content):
882
 
                raise self.err
883
 
            def close(self):
884
 
                pass
885
 
        # All of these should be treated as ConnectionReset
886
 
        errs = []
887
 
        for err_cls in (IOError, socket.error):
888
 
            for errnum in osutils._end_of_stream_errors:
889
 
                errs.append(err_cls(errnum))
890
 
        for err in errs:
891
 
            sock = DisconnectedSocket(err)
892
 
            self.assertRaises(errors.ConnectionReset,
893
 
                osutils.send_all, sock, 'some more content')
894
 
 
895
 
    def test_send_with_no_progress(self):
896
 
        # See https://bugs.launchpad.net/bzr/+bug/1047309
897
 
        # It seems that paramiko can get into a state where it doesn't error,
898
 
        # but it returns 0 bytes sent for requests over and over again.
899
 
        class NoSendingSocket(object):
900
 
            def __init__(self):
901
 
                self.call_count = 0
902
 
            def send(self, bytes):
903
 
                self.call_count += 1
904
 
                if self.call_count > 100:
905
 
                    # Prevent the test suite from hanging
906
 
                    raise RuntimeError('too many calls')
907
 
                return 0
908
 
        sock = NoSendingSocket()
909
 
        self.assertRaises(errors.ConnectionReset,
910
 
                          osutils.send_all, sock, 'content')
911
 
        self.assertEqual(1, sock.call_count)
912
 
 
913
 
 
914
 
class TestPosixFuncs(tests.TestCase):
915
 
    """Test that the posix version of normpath returns an appropriate path
916
 
       when used with 2 leading slashes."""
917
 
 
918
 
    def test_normpath(self):
919
 
        self.assertEqual('/etc/shadow', osutils._posix_normpath('/etc/shadow'))
920
 
        self.assertEqual('/etc/shadow', osutils._posix_normpath('//etc/shadow'))
921
 
        self.assertEqual('/etc/shadow', osutils._posix_normpath('///etc/shadow'))
922
 
 
923
 
 
924
821
class TestWin32Funcs(tests.TestCase):
925
822
    """Test that _win32 versions of os utilities return appropriate paths."""
926
823
 
927
824
    def test_abspath(self):
928
 
        self.requireFeature(features.win32_feature)
929
825
        self.assertEqual('C:/foo', osutils._win32_abspath('C:\\foo'))
930
826
        self.assertEqual('C:/foo', osutils._win32_abspath('C:/foo'))
931
827
        self.assertEqual('//HOST/path', osutils._win32_abspath(r'\\HOST\path'))
944
840
                         osutils._win32_pathjoin('path/to', 'C:/foo'))
945
841
        self.assertEqual('path/to/foo',
946
842
                         osutils._win32_pathjoin('path/to/', 'foo'))
947
 
 
948
 
    def test_pathjoin_late_bugfix(self):
949
 
        if sys.version_info < (2, 7, 6):
950
 
            expected = '/foo'
951
 
        else:
952
 
            expected = 'C:/foo'
953
 
        self.assertEqual(expected,
 
843
        self.assertEqual('/foo',
954
844
                         osutils._win32_pathjoin('C:/path/to/', '/foo'))
955
 
        self.assertEqual(expected,
 
845
        self.assertEqual('/foo',
956
846
                         osutils._win32_pathjoin('C:\\path\\to\\', '\\foo'))
957
847
 
958
848
    def test_normpath(self):
978
868
        self.assertEqual('C:\\foo', osutils._win32_fixdrive('c:\\foo'))
979
869
 
980
870
    def test_win98_abspath(self):
981
 
        self.requireFeature(features.win32_feature)
982
871
        # absolute path
983
872
        self.assertEqual('C:/foo', osutils._win98_abspath('C:\\foo'))
984
873
        self.assertEqual('C:/foo', osutils._win98_abspath('C:/foo'))
1205
1094
        # (It would be ok if it happened earlier but at the moment it
1206
1095
        # doesn't.)
1207
1096
        e = self.assertRaises(OSError, list, osutils._walkdirs_utf8("."))
1208
 
        self.assertEqual('./test-unreadable', e.filename)
1209
 
        self.assertEqual(errno.EACCES, e.errno)
 
1097
        self.assertEquals('./test-unreadable', e.filename)
 
1098
        self.assertEquals(errno.EACCES, e.errno)
1210
1099
        # Ensure the message contains the file name
1211
1100
        self.assertContainsRe(str(e), "\./test-unreadable")
1212
1101
 
1317
1206
        self.requireFeature(UTF8DirReaderFeature)
1318
1207
        self._save_platform_info()
1319
1208
        win32utils.winver = None # Avoid the win32 detection code
1320
 
        osutils._fs_enc = 'utf-8'
 
1209
        osutils._fs_enc = 'UTF-8'
1321
1210
        self.assertDirReaderIs(
1322
1211
            UTF8DirReaderFeature.module.UTF8DirReader)
1323
1212
 
1325
1214
        self.requireFeature(UTF8DirReaderFeature)
1326
1215
        self._save_platform_info()
1327
1216
        win32utils.winver = None # Avoid the win32 detection code
1328
 
        osutils._fs_enc = 'ascii'
 
1217
        osutils._fs_enc = 'US-ASCII'
 
1218
        self.assertDirReaderIs(
 
1219
            UTF8DirReaderFeature.module.UTF8DirReader)
 
1220
 
 
1221
    def test_force_walkdirs_utf8_fs_ANSI(self):
 
1222
        self.requireFeature(UTF8DirReaderFeature)
 
1223
        self._save_platform_info()
 
1224
        win32utils.winver = None # Avoid the win32 detection code
 
1225
        osutils._fs_enc = 'ANSI_X3.4-1968'
1329
1226
        self.assertDirReaderIs(
1330
1227
            UTF8DirReaderFeature.module.UTF8DirReader)
1331
1228
 
1332
1229
    def test_force_walkdirs_utf8_fs_latin1(self):
1333
1230
        self._save_platform_info()
1334
1231
        win32utils.winver = None # Avoid the win32 detection code
1335
 
        osutils._fs_enc = 'iso-8859-1'
 
1232
        osutils._fs_enc = 'latin1'
1336
1233
        self.assertDirReaderIs(osutils.UnicodeDirReader)
1337
1234
 
1338
1235
    def test_force_walkdirs_utf8_nt(self):
1862
1759
    _native_to_unicode = None
1863
1760
 
1864
1761
    def setUp(self):
1865
 
        super(TestDirReader, self).setUp()
 
1762
        tests.TestCaseInTempDir.setUp(self)
1866
1763
        self.overrideAttr(osutils,
1867
1764
                          '_selected_dir_reader', self._dir_reader_class())
1868
1765
 
2003
1900
        os.symlink(self.target, self.link)
2004
1901
 
2005
1902
    def test_os_readlink_link_encoding(self):
2006
 
        self.assertEqual(self.target,  os.readlink(self.link))
 
1903
        self.assertEquals(self.target,  os.readlink(self.link))
2007
1904
 
2008
1905
    def test_os_readlink_link_decoding(self):
2009
 
        self.assertEqual(self.target.encode(osutils._fs_enc),
 
1906
        self.assertEquals(self.target.encode(osutils._fs_enc),
2010
1907
                          os.readlink(self.link.encode(osutils._fs_enc)))
2011
1908
 
2012
1909
 
2032
1929
        self.overrideEnv('BZR_CONCURRENCY', '1')
2033
1930
        self.run_bzr('rocks --concurrency 42')
2034
1931
        # Command line overrides environment variable
2035
 
        self.assertEqual('42', os.environ['BZR_CONCURRENCY'])
2036
 
        self.assertEqual(42, osutils.local_concurrency(use_cache=False))
 
1932
        self.assertEquals('42', os.environ['BZR_CONCURRENCY'])
 
1933
        self.assertEquals(42, osutils.local_concurrency(use_cache=False))
2037
1934
 
2038
1935
 
2039
1936
class TestFailedToLoadExtension(tests.TestCase):
2052
1949
    def test_failure_to_load(self):
2053
1950
        self._try_loading()
2054
1951
        self.assertLength(1, osutils._extension_load_failures)
2055
 
        self.assertEqual(osutils._extension_load_failures[0],
 
1952
        self.assertEquals(osutils._extension_load_failures[0],
2056
1953
            "No module named _fictional_extension_py")
2057
1954
 
2058
1955
    def test_report_extension_load_failures_no_warning(self):
2076
1973
class TestTerminalWidth(tests.TestCase):
2077
1974
 
2078
1975
    def setUp(self):
2079
 
        super(TestTerminalWidth, self).setUp()
 
1976
        tests.TestCase.setUp(self)
2080
1977
        self._orig_terminal_size_state = osutils._terminal_size_state
2081
1978
        self._orig_first_terminal_size = osutils._first_terminal_size
2082
1979
        self.addCleanup(self.restore_osutils_globals)
2163
2060
    _test_needs_features = [features.chown_feature]
2164
2061
 
2165
2062
    def setUp(self):
2166
 
        super(TestCreationOps, self).setUp()
 
2063
        tests.TestCaseInTempDir.setUp(self)
2167
2064
        self.overrideAttr(os, 'chown', self._dummy_chown)
2168
2065
 
2169
2066
        # params set by call to _dummy_chown
2179
2076
        osutils.copy_ownership_from_path('test_file', ownsrc)
2180
2077
 
2181
2078
        s = os.stat(ownsrc)
2182
 
        self.assertEqual(self.path, 'test_file')
2183
 
        self.assertEqual(self.uid, s.st_uid)
2184
 
        self.assertEqual(self.gid, s.st_gid)
 
2079
        self.assertEquals(self.path, 'test_file')
 
2080
        self.assertEquals(self.uid, s.st_uid)
 
2081
        self.assertEquals(self.gid, s.st_gid)
2185
2082
 
2186
2083
    def test_copy_ownership_nonesrc(self):
2187
2084
        """copy_ownership_from_path test with src=None."""
2190
2087
        osutils.copy_ownership_from_path('test_file')
2191
2088
 
2192
2089
        s = os.stat('..')
2193
 
        self.assertEqual(self.path, 'test_file')
2194
 
        self.assertEqual(self.uid, s.st_uid)
2195
 
        self.assertEqual(self.gid, s.st_gid)
2196
 
 
2197
 
 
2198
 
class TestPathFromEnviron(tests.TestCase):
2199
 
 
2200
 
    def test_is_unicode(self):
2201
 
        self.overrideEnv('BZR_TEST_PATH', './anywhere at all/')
2202
 
        path = osutils.path_from_environ('BZR_TEST_PATH')
2203
 
        self.assertIsInstance(path, unicode)
2204
 
        self.assertEqual(u'./anywhere at all/', path)
2205
 
 
2206
 
    def test_posix_path_env_ascii(self):
2207
 
        self.overrideEnv('BZR_TEST_PATH', '/tmp')
2208
 
        home = osutils._posix_path_from_environ('BZR_TEST_PATH')
2209
 
        self.assertIsInstance(home, unicode)
2210
 
        self.assertEqual(u'/tmp', home)
2211
 
 
2212
 
    def test_posix_path_env_unicode(self):
2213
 
        self.requireFeature(features.ByteStringNamedFilesystem)
2214
 
        self.overrideEnv('BZR_TEST_PATH', '/home/\xa7test')
2215
 
        self.overrideAttr(osutils, "_fs_enc", "iso8859-1")
2216
 
        self.assertEqual(u'/home/\xa7test',
2217
 
            osutils._posix_path_from_environ('BZR_TEST_PATH'))
2218
 
        osutils._fs_enc = "iso8859-5"
2219
 
        self.assertEqual(u'/home/\u0407test',
2220
 
            osutils._posix_path_from_environ('BZR_TEST_PATH'))
2221
 
        osutils._fs_enc = "utf-8"
2222
 
        self.assertRaises(errors.BadFilenameEncoding,
2223
 
            osutils._posix_path_from_environ, 'BZR_TEST_PATH')
2224
 
 
2225
 
 
2226
 
class TestGetHomeDir(tests.TestCase):
2227
 
 
2228
 
    def test_is_unicode(self):
2229
 
        home = osutils._get_home_dir()
2230
 
        self.assertIsInstance(home, unicode)
2231
 
 
2232
 
    def test_posix_homeless(self):
2233
 
        self.overrideEnv('HOME', None)
2234
 
        home = osutils._get_home_dir()
2235
 
        self.assertIsInstance(home, unicode)
2236
 
 
2237
 
    def test_posix_home_ascii(self):
2238
 
        self.overrideEnv('HOME', '/home/test')
2239
 
        home = osutils._posix_get_home_dir()
2240
 
        self.assertIsInstance(home, unicode)
2241
 
        self.assertEqual(u'/home/test', home)
2242
 
 
2243
 
    def test_posix_home_unicode(self):
2244
 
        self.requireFeature(features.ByteStringNamedFilesystem)
2245
 
        self.overrideEnv('HOME', '/home/\xa7test')
2246
 
        self.overrideAttr(osutils, "_fs_enc", "iso8859-1")
2247
 
        self.assertEqual(u'/home/\xa7test', osutils._posix_get_home_dir())
2248
 
        osutils._fs_enc = "iso8859-5"
2249
 
        self.assertEqual(u'/home/\u0407test', osutils._posix_get_home_dir())
2250
 
        osutils._fs_enc = "utf-8"
2251
 
        self.assertRaises(errors.BadFilenameEncoding,
2252
 
            osutils._posix_get_home_dir)
 
2090
        self.assertEquals(self.path, 'test_file')
 
2091
        self.assertEquals(self.uid, s.st_uid)
 
2092
        self.assertEquals(self.gid, s.st_gid)
2253
2093
 
2254
2094
 
2255
2095
class TestGetuserUnicode(tests.TestCase):
2256
2096
 
2257
 
    def test_is_unicode(self):
2258
 
        user = osutils.getuser_unicode()
2259
 
        self.assertIsInstance(user, unicode)
2260
 
 
2261
 
    def envvar_to_override(self):
2262
 
        if sys.platform == "win32":
2263
 
            # Disable use of platform calls on windows so envvar is used
2264
 
            self.overrideAttr(win32utils, 'has_ctypes', False)
2265
 
            return 'USERNAME' # only variable used on windows
2266
 
        return 'LOGNAME' # first variable checked by getpass.getuser()
2267
 
 
2268
2097
    def test_ascii_user(self):
2269
 
        self.overrideEnv(self.envvar_to_override(), 'jrandom')
 
2098
        self.overrideEnv('LOGNAME', 'jrandom')
2270
2099
        self.assertEqual(u'jrandom', osutils.getuser_unicode())
2271
2100
 
2272
2101
    def test_unicode_user(self):
2278
2107
                % (osutils.get_user_encoding(),))
2279
2108
        uni_username = u'jrandom' + uni_val
2280
2109
        encoded_username = uni_username.encode(ue)
2281
 
        self.overrideEnv(self.envvar_to_override(), encoded_username)
 
2110
        self.overrideEnv('LOGNAME', encoded_username)
2282
2111
        self.assertEqual(uni_username, osutils.getuser_unicode())
 
2112
        self.overrideEnv('LOGNAME', u'jrandom\xb6'.encode(ue))
 
2113
        self.assertEqual(u'jrandom\xb6', osutils.getuser_unicode())
 
2114
 
 
2115
    def test_no_username_bug_660174(self):
 
2116
        self.requireFeature(features.win32_feature)
 
2117
        for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
 
2118
            self.overrideEnv(name, None)
 
2119
        self.assertEqual(u'UNKNOWN', osutils.getuser_unicode())
2283
2120
 
2284
2121
 
2285
2122
class TestBackupNames(tests.TestCase):
2325
2162
        self.assertTrue(
2326
2163
            osutils.find_executable_on_path('THIS SHOULD NOT EXIST') is None)
2327
2164
        self.assertTrue(osutils.find_executable_on_path('file.txt') is None)
2328
 
        
2329
 
    def test_windows_app_path(self):
2330
 
        if sys.platform != 'win32':
2331
 
            raise tests.TestSkipped('test requires win32')
2332
 
        # Override PATH env var so that exe can only be found on App Path
2333
 
        self.overrideEnv('PATH', '')
2334
 
        # Internt Explorer is always registered in the App Path
2335
 
        self.assertTrue(osutils.find_executable_on_path('iexplore') is not None)
2336
2165
 
2337
2166
    def test_other(self):
2338
2167
        if sys.platform == 'win32':
2340
2169
        self.assertTrue(osutils.find_executable_on_path('sh') is not None)
2341
2170
        self.assertTrue(
2342
2171
            osutils.find_executable_on_path('THIS SHOULD NOT EXIST') is None)
2343
 
 
2344
 
 
2345
 
class TestEnvironmentErrors(tests.TestCase):
2346
 
    """Test handling of environmental errors"""
2347
 
 
2348
 
    def test_is_oserror(self):
2349
 
        self.assertTrue(osutils.is_environment_error(
2350
 
            OSError(errno.EINVAL, "Invalid parameter")))
2351
 
 
2352
 
    def test_is_ioerror(self):
2353
 
        self.assertTrue(osutils.is_environment_error(
2354
 
            IOError(errno.EINVAL, "Invalid parameter")))
2355
 
 
2356
 
    def test_is_socket_error(self):
2357
 
        self.assertTrue(osutils.is_environment_error(
2358
 
            socket.error(errno.EINVAL, "Invalid parameter")))
2359
 
 
2360
 
    def test_is_select_error(self):
2361
 
        self.assertTrue(osutils.is_environment_error(
2362
 
            select.error(errno.EINVAL, "Invalid parameter")))
2363
 
 
2364
 
    def test_is_pywintypes_error(self):
2365
 
        self.requireFeature(features.pywintypes)
2366
 
        import pywintypes
2367
 
        self.assertTrue(osutils.is_environment_error(
2368
 
            pywintypes.error(errno.EINVAL, "Invalid parameter", "Caller")))