72
53
UTF8DirReaderFeature = _UTF8DirReaderFeature()
75
class TestOSUtils(TestCaseInTempDir):
56
def _already_unicode(s):
60
def _fs_enc_to_unicode(s):
61
return s.decode(osutils._fs_enc)
64
def _utf8_to_unicode(s):
65
return s.decode('UTF-8')
68
def dir_reader_scenarios():
69
# For each dir reader we define:
71
# - native_to_unicode: a function converting the native_abspath as returned
72
# by DirReader.read_dir to its unicode representation
74
# UnicodeDirReader is the fallback, it should be tested on all platforms.
75
scenarios = [('unicode',
76
dict(_dir_reader_class=osutils.UnicodeDirReader,
77
_native_to_unicode=_already_unicode))]
78
# Some DirReaders are platform specific and even there they may not be
80
if UTF8DirReaderFeature.available():
81
from bzrlib import _readdir_pyx
82
scenarios.append(('utf8',
83
dict(_dir_reader_class=_readdir_pyx.UTF8DirReader,
84
_native_to_unicode=_utf8_to_unicode)))
86
if test__walkdirs_win32.Win32ReadDirFeature.available():
88
from bzrlib import _walkdirs_win32
89
# TODO: check on windows, it may be that we need to use/add
90
# safe_unicode instead of _fs_enc_to_unicode
93
dict(_dir_reader_class=_walkdirs_win32.Win32ReadDir,
94
_native_to_unicode=_fs_enc_to_unicode)))
100
def load_tests(basic_tests, module, loader):
101
suite = loader.suiteClass()
102
dir_reader_tests, remaining_tests = tests.split_suite_by_condition(
103
basic_tests, tests.condition_isinstance(TestDirReader))
104
tests.multiply_tests(dir_reader_tests, dir_reader_scenarios(), suite)
105
suite.addTest(remaining_tests)
109
class TestContainsWhitespace(tests.TestCase):
77
111
def test_contains_whitespace(self):
78
112
self.failUnless(osutils.contains_whitespace(u' '))
151
194
self.assertTrue(is_inside('', 'foo.c'))
153
196
def test_is_inside_any(self):
154
SRC_FOO_C = pathjoin('src', 'foo.c')
197
SRC_FOO_C = osutils.pathjoin('src', 'foo.c')
155
198
for dirs, fn in [(['src', 'doc'], SRC_FOO_C),
156
199
(['src'], SRC_FOO_C),
157
200
(['src'], 'src'),
159
self.assert_(is_inside_any(dirs, fn))
202
self.assert_(osutils.is_inside_any(dirs, fn))
160
203
for dirs, fn in [(['src'], 'srccontrol'),
161
204
(['src'], 'srccontrol/foo')]:
162
self.assertFalse(is_inside_any(dirs, fn))
205
self.assertFalse(osutils.is_inside_any(dirs, fn))
164
207
def test_is_inside_or_parent_of_any(self):
165
208
for dirs, fn in [(['src', 'doc'], 'src/foo.c'),
298
353
# Instead blackbox.test_locale should check for localized
299
354
# dates once they do occur in output strings.
356
def test_local_time_offset(self):
357
"""Test that local_time_offset() returns a sane value."""
358
offset = osutils.local_time_offset()
359
self.assertTrue(isinstance(offset, int))
360
# Test that the offset is no more than a eighteen hours in
362
# Time zone handling is system specific, so it is difficult to
363
# do more specific tests, but a value outside of this range is
365
eighteen_hours = 18 * 3600
366
self.assertTrue(-eighteen_hours < offset < eighteen_hours)
368
def test_local_time_offset_with_timestamp(self):
369
"""Test that local_time_offset() works with a timestamp."""
370
offset = osutils.local_time_offset(1000000000.1234567)
371
self.assertTrue(isinstance(offset, int))
372
eighteen_hours = 18 * 3600
373
self.assertTrue(-eighteen_hours < offset < eighteen_hours)
376
class TestLinks(tests.TestCaseInTempDir):
301
378
def test_dereference_path(self):
302
self.requireFeature(SymlinkFeature)
379
self.requireFeature(tests.SymlinkFeature)
303
380
cwd = osutils.realpath('.')
305
382
bar_path = osutils.pathjoin(cwd, 'bar')
346
423
osutils.make_readonly('dangling')
347
424
osutils.make_writable('dangling')
349
def test_kind_marker(self):
350
self.assertEqual("", osutils.kind_marker("file"))
351
self.assertEqual("/", osutils.kind_marker(osutils._directory_kind))
352
self.assertEqual("@", osutils.kind_marker("symlink"))
353
self.assertRaises(errors.BzrError, osutils.kind_marker, "unknown")
355
426
def test_host_os_dereferences_symlinks(self):
356
427
osutils.host_os_dereferences_symlinks()
359
class TestCanonicalRelPath(TestCaseInTempDir):
430
class TestCanonicalRelPath(tests.TestCaseInTempDir):
361
_test_needs_features = [CaseInsCasePresFilenameFeature]
432
_test_needs_features = [tests.CaseInsCasePresFilenameFeature]
363
434
def test_canonical_relpath_simple(self):
364
435
f = file('MixedCaseName', 'w')
366
self.failUnlessEqual(
367
canonical_relpath(self.test_base_dir, 'mixedcasename'),
368
'work/MixedCaseName')
437
# Watch out for tricky test dir (on OSX /tmp -> /private/tmp)
438
real_base_dir = osutils.realpath(self.test_base_dir)
439
actual = osutils.canonical_relpath(real_base_dir, 'mixedcasename')
440
self.failUnlessEqual('work/MixedCaseName', actual)
370
442
def test_canonical_relpath_missing_tail(self):
371
443
os.mkdir('MixedCaseParent')
372
self.failUnlessEqual(
373
canonical_relpath(self.test_base_dir, 'mixedcaseparent/nochild'),
374
'work/MixedCaseParent/nochild')
377
class TestPumpFile(TestCase):
444
# Watch out for tricky test dir (on OSX /tmp -> /private/tmp)
445
real_base_dir = osutils.realpath(self.test_base_dir)
446
actual = osutils.canonical_relpath(real_base_dir,
447
'mixedcaseparent/nochild')
448
self.failUnlessEqual('work/MixedCaseParent/nochild', actual)
451
class TestPumpFile(tests.TestCase):
378
452
"""Test pumpfile method."""
455
tests.TestCase.setUp(self)
381
456
# create a test datablock
382
457
self.block_size = 512
383
458
pattern = '0123456789ABCDEF'
390
465
# make sure test data is larger than max read size
391
466
self.assertTrue(self.test_data_len > self.block_size)
393
from_file = FakeReadFile(self.test_data)
468
from_file = file_utils.FakeReadFile(self.test_data)
394
469
to_file = StringIO()
396
471
# read (max / 2) bytes and verify read size wasn't affected
397
472
num_bytes_to_read = self.block_size / 2
398
pumpfile(from_file, to_file, num_bytes_to_read, self.block_size)
473
osutils.pumpfile(from_file, to_file, num_bytes_to_read, self.block_size)
399
474
self.assertEqual(from_file.get_max_read_size(), num_bytes_to_read)
400
475
self.assertEqual(from_file.get_read_count(), 1)
402
477
# read (max) bytes and verify read size wasn't affected
403
478
num_bytes_to_read = self.block_size
404
479
from_file.reset_read_count()
405
pumpfile(from_file, to_file, num_bytes_to_read, self.block_size)
480
osutils.pumpfile(from_file, to_file, num_bytes_to_read, self.block_size)
406
481
self.assertEqual(from_file.get_max_read_size(), num_bytes_to_read)
407
482
self.assertEqual(from_file.get_read_count(), 1)
409
484
# read (max + 1) bytes and verify read size was limited
410
485
num_bytes_to_read = self.block_size + 1
411
486
from_file.reset_read_count()
412
pumpfile(from_file, to_file, num_bytes_to_read, self.block_size)
487
osutils.pumpfile(from_file, to_file, num_bytes_to_read, self.block_size)
413
488
self.assertEqual(from_file.get_max_read_size(), self.block_size)
414
489
self.assertEqual(from_file.get_read_count(), 2)
416
491
# finish reading the rest of the data
417
492
num_bytes_to_read = self.test_data_len - to_file.tell()
418
pumpfile(from_file, to_file, num_bytes_to_read, self.block_size)
493
osutils.pumpfile(from_file, to_file, num_bytes_to_read, self.block_size)
420
495
# report error if the data wasn't equal (we only report the size due
421
496
# to the length of the data)
491
567
activity.append((length, direction))
492
568
from_file = StringIO(self.test_data)
493
569
to_file = StringIO()
494
pumpfile(from_file, to_file, buff_size=500,
495
report_activity=log_activity, direction='read')
570
osutils.pumpfile(from_file, to_file, buff_size=500,
571
report_activity=log_activity, direction='read')
496
572
self.assertEqual([(500, 'read'), (500, 'read'), (500, 'read'),
497
573
(36, 'read')], activity)
499
575
from_file = StringIO(self.test_data)
500
576
to_file = StringIO()
502
pumpfile(from_file, to_file, buff_size=500,
503
report_activity=log_activity, direction='write')
578
osutils.pumpfile(from_file, to_file, buff_size=500,
579
report_activity=log_activity, direction='write')
504
580
self.assertEqual([(500, 'write'), (500, 'write'), (500, 'write'),
505
581
(36, 'write')], activity)
508
584
from_file = StringIO(self.test_data)
509
585
to_file = StringIO()
511
pumpfile(from_file, to_file, buff_size=500, read_length=1028,
512
report_activity=log_activity, direction='read')
587
osutils.pumpfile(from_file, to_file, buff_size=500, read_length=1028,
588
report_activity=log_activity, direction='read')
513
589
self.assertEqual([(500, 'read'), (500, 'read'), (28, 'read')], activity)
517
class TestPumpStringFile(TestCase):
593
class TestPumpStringFile(tests.TestCase):
519
595
def test_empty(self):
520
596
output = StringIO()
521
pump_string_file("", output)
597
osutils.pump_string_file("", output)
522
598
self.assertEqual("", output.getvalue())
524
600
def test_more_than_segment_size(self):
525
601
output = StringIO()
526
pump_string_file("123456789", output, 2)
602
osutils.pump_string_file("123456789", output, 2)
527
603
self.assertEqual("123456789", output.getvalue())
529
605
def test_segment_size(self):
530
606
output = StringIO()
531
pump_string_file("12", output, 2)
607
osutils.pump_string_file("12", output, 2)
532
608
self.assertEqual("12", output.getvalue())
534
610
def test_segment_size_multiple(self):
535
611
output = StringIO()
536
pump_string_file("1234", output, 2)
612
osutils.pump_string_file("1234", output, 2)
537
613
self.assertEqual("1234", output.getvalue())
540
class TestSafeUnicode(TestCase):
616
class TestSafeUnicode(tests.TestCase):
542
618
def test_from_ascii_string(self):
543
619
self.assertEqual(u'foobar', osutils.safe_unicode('foobar'))
645
721
self.assertEqual('C:/foo', osutils._win32_realpath('C:/foo'))
647
723
def test_pathjoin(self):
648
self.assertEqual('path/to/foo', osutils._win32_pathjoin('path', 'to', 'foo'))
649
self.assertEqual('C:/foo', osutils._win32_pathjoin('path\\to', 'C:\\foo'))
650
self.assertEqual('C:/foo', osutils._win32_pathjoin('path/to', 'C:/foo'))
651
self.assertEqual('path/to/foo', osutils._win32_pathjoin('path/to/', 'foo'))
652
self.assertEqual('/foo', osutils._win32_pathjoin('C:/path/to/', '/foo'))
653
self.assertEqual('/foo', osutils._win32_pathjoin('C:\\path\\to\\', '\\foo'))
724
self.assertEqual('path/to/foo',
725
osutils._win32_pathjoin('path', 'to', 'foo'))
726
self.assertEqual('C:/foo',
727
osutils._win32_pathjoin('path\\to', 'C:\\foo'))
728
self.assertEqual('C:/foo',
729
osutils._win32_pathjoin('path/to', 'C:/foo'))
730
self.assertEqual('path/to/foo',
731
osutils._win32_pathjoin('path/to/', 'foo'))
732
self.assertEqual('/foo',
733
osutils._win32_pathjoin('C:/path/to/', '/foo'))
734
self.assertEqual('/foo',
735
osutils._win32_pathjoin('C:\\path\\to\\', '\\foo'))
655
737
def test_normpath(self):
656
self.assertEqual('path/to/foo', osutils._win32_normpath(r'path\\from\..\to\.\foo'))
657
self.assertEqual('path/to/foo', osutils._win32_normpath('path//from/../to/./foo'))
738
self.assertEqual('path/to/foo',
739
osutils._win32_normpath(r'path\\from\..\to\.\foo'))
740
self.assertEqual('path/to/foo',
741
osutils._win32_normpath('path//from/../to/./foo'))
659
743
def test_getcwd(self):
660
744
cwd = osutils._win32_getcwd()
711
789
def test_minimum_path_selection(self):
712
790
self.assertEqual(set(),
713
791
osutils.minimum_path_selection([]))
792
self.assertEqual(set(['a']),
793
osutils.minimum_path_selection(['a']))
714
794
self.assertEqual(set(['a', 'b']),
715
795
osutils.minimum_path_selection(['a', 'b']))
716
796
self.assertEqual(set(['a/', 'b']),
717
797
osutils.minimum_path_selection(['a/', 'b']))
718
798
self.assertEqual(set(['a/', 'b']),
719
799
osutils.minimum_path_selection(['a/c', 'a/', 'b']))
800
self.assertEqual(set(['a-b', 'a', 'a0b']),
801
osutils.minimum_path_selection(['a-b', 'a/b', 'a0b', 'a']))
721
803
def test_mkdtemp(self):
722
804
tmpdir = osutils._win32_mkdtemp(dir='.')
778
860
self.assertRaises(errors.BzrError, osutils.splitpath, 'a/../b')
781
class TestMacFuncsDirs(TestCaseInTempDir):
863
class TestParentDirectories(tests.TestCaseInTempDir):
864
"""Test osutils.parent_directories()"""
866
def test_parent_directories(self):
867
self.assertEqual([], osutils.parent_directories('a'))
868
self.assertEqual(['a'], osutils.parent_directories('a/b'))
869
self.assertEqual(['a/b', 'a'], osutils.parent_directories('a/b/c'))
872
class TestMacFuncsDirs(tests.TestCaseInTempDir):
782
873
"""Test mac special functions that require directories."""
784
875
def test_getcwd(self):
785
# On Mac, this will actually create Ba\u030agfors
786
# but chdir will still work, because it accepts both paths
788
os.mkdir(u'B\xe5gfors')
790
raise TestSkipped("Unable to create Unicode filename")
876
self.requireFeature(tests.UnicodeFilenameFeature)
877
os.mkdir(u'B\xe5gfors')
792
878
os.chdir(u'B\xe5gfors')
793
879
self.assertEndsWith(osutils._mac_getcwd(), u'B\xe5gfors')
795
881
def test_getcwd_nonnorm(self):
882
self.requireFeature(tests.UnicodeFilenameFeature)
796
883
# Test that _mac_getcwd() will normalize this path
798
os.mkdir(u'Ba\u030agfors')
800
raise TestSkipped("Unable to create Unicode filename")
884
os.mkdir(u'Ba\u030agfors')
802
885
os.chdir(u'Ba\u030agfors')
803
886
self.assertEndsWith(osutils._mac_getcwd(), u'B\xe5gfors')
806
class TestChunksToLines(TestCase):
889
class TestChunksToLines(tests.TestCase):
808
891
def test_smoketest(self):
809
892
self.assertEqual(['foo\n', 'bar\n', 'baz\n'],
979
1064
self._save_platform_info()
980
1065
win32utils.winver = None # Avoid the win32 detection code
981
1066
osutils._fs_enc = 'UTF-8'
982
self.assertReadFSDirIs(UTF8DirReaderFeature.reader)
1067
self.assertDirReaderIs(UTF8DirReaderFeature.reader)
984
1069
def test_force_walkdirs_utf8_fs_ascii(self):
985
1070
self.requireFeature(UTF8DirReaderFeature)
986
1071
self._save_platform_info()
987
1072
win32utils.winver = None # Avoid the win32 detection code
988
1073
osutils._fs_enc = 'US-ASCII'
989
self.assertReadFSDirIs(UTF8DirReaderFeature.reader)
1074
self.assertDirReaderIs(UTF8DirReaderFeature.reader)
991
1076
def test_force_walkdirs_utf8_fs_ANSI(self):
992
1077
self.requireFeature(UTF8DirReaderFeature)
993
1078
self._save_platform_info()
994
1079
win32utils.winver = None # Avoid the win32 detection code
995
1080
osutils._fs_enc = 'ANSI_X3.4-1968'
996
self.assertReadFSDirIs(UTF8DirReaderFeature.reader)
1081
self.assertDirReaderIs(UTF8DirReaderFeature.reader)
998
1083
def test_force_walkdirs_utf8_fs_latin1(self):
999
1084
self._save_platform_info()
1000
1085
win32utils.winver = None # Avoid the win32 detection code
1001
1086
osutils._fs_enc = 'latin1'
1002
self.assertReadFSDirIs(osutils.UnicodeDirReader)
1087
self.assertDirReaderIs(osutils.UnicodeDirReader)
1004
1089
def test_force_walkdirs_utf8_nt(self):
1005
1090
# Disabled because the thunk of the whole walkdirs api is disabled.
1006
self.requireFeature(Win32ReadDirFeature)
1091
self.requireFeature(test__walkdirs_win32.Win32ReadDirFeature)
1007
1092
self._save_platform_info()
1008
1093
win32utils.winver = 'Windows NT'
1009
1094
from bzrlib._walkdirs_win32 import Win32ReadDir
1010
self.assertReadFSDirIs(Win32ReadDir)
1095
self.assertDirReaderIs(Win32ReadDir)
1012
1097
def test_force_walkdirs_utf8_98(self):
1013
self.requireFeature(Win32ReadDirFeature)
1098
self.requireFeature(test__walkdirs_win32.Win32ReadDirFeature)
1014
1099
self._save_platform_info()
1015
1100
win32utils.winver = 'Windows 98'
1016
self.assertReadFSDirIs(osutils.UnicodeDirReader)
1101
self.assertDirReaderIs(osutils.UnicodeDirReader)
1018
1103
def test_unicode_walkdirs(self):
1019
1104
"""Walkdirs should always return unicode paths."""
1105
self.requireFeature(tests.UnicodeFilenameFeature)
1020
1106
name0 = u'0file-\xb6'
1021
1107
name1 = u'1dir-\u062c\u0648'
1022
1108
name2 = u'2file-\u0633'
1454
1527
self.failIf('BZR_TEST_ENV_VAR' in os.environ)
1457
class TestLocalTimeOffset(TestCase):
1459
def test_local_time_offset(self):
1460
"""Test that local_time_offset() returns a sane value."""
1461
offset = osutils.local_time_offset()
1462
self.assertTrue(isinstance(offset, int))
1463
# Test that the offset is no more than a eighteen hours in
1465
# Time zone handling is system specific, so it is difficult to
1466
# do more specific tests, but a value outside of this range is
1468
eighteen_hours = 18 * 3600
1469
self.assertTrue(-eighteen_hours < offset < eighteen_hours)
1471
def test_local_time_offset_with_timestamp(self):
1472
"""Test that local_time_offset() works with a timestamp."""
1473
offset = osutils.local_time_offset(1000000000.1234567)
1474
self.assertTrue(isinstance(offset, int))
1475
eighteen_hours = 18 * 3600
1476
self.assertTrue(-eighteen_hours < offset < eighteen_hours)
1479
class TestSizeShaFile(TestCaseInTempDir):
1530
class TestSizeShaFile(tests.TestCaseInTempDir):
1481
1532
def test_sha_empty(self):
1482
1533
self.build_tree_contents([('foo', '')])
1544
1595
"Invalid regular expression in test case: '*': "
1545
1596
"nothing to repeat",
1600
class TestDirReader(tests.TestCaseInTempDir):
1603
_dir_reader_class = None
1604
_native_to_unicode = None
1607
tests.TestCaseInTempDir.setUp(self)
1609
# Save platform specific info and reset it
1610
cur_dir_reader = osutils._selected_dir_reader
1613
osutils._selected_dir_reader = cur_dir_reader
1614
self.addCleanup(restore)
1616
osutils._selected_dir_reader = self._dir_reader_class()
1618
def _get_ascii_tree(self):
1626
expected_dirblocks = [
1628
[('0file', '0file', 'file'),
1629
('1dir', '1dir', 'directory'),
1630
('2file', '2file', 'file'),
1633
(('1dir', './1dir'),
1634
[('1dir/0file', '0file', 'file'),
1635
('1dir/1dir', '1dir', 'directory'),
1638
(('1dir/1dir', './1dir/1dir'),
1643
return tree, expected_dirblocks
1645
def test_walk_cur_dir(self):
1646
tree, expected_dirblocks = self._get_ascii_tree()
1647
self.build_tree(tree)
1648
result = list(osutils._walkdirs_utf8('.'))
1649
# Filter out stat and abspath
1650
self.assertEqual(expected_dirblocks,
1651
[(dirinfo, [line[0:3] for line in block])
1652
for dirinfo, block in result])
1654
def test_walk_sub_dir(self):
1655
tree, expected_dirblocks = self._get_ascii_tree()
1656
self.build_tree(tree)
1657
# you can search a subdir only, with a supplied prefix.
1658
result = list(osutils._walkdirs_utf8('./1dir', '1dir'))
1659
# Filter out stat and abspath
1660
self.assertEqual(expected_dirblocks[1:],
1661
[(dirinfo, [line[0:3] for line in block])
1662
for dirinfo, block in result])
1664
def _get_unicode_tree(self):
1665
name0u = u'0file-\xb6'
1666
name1u = u'1dir-\u062c\u0648'
1667
name2u = u'2file-\u0633'
1671
name1u + '/' + name0u,
1672
name1u + '/' + name1u + '/',
1675
name0 = name0u.encode('UTF-8')
1676
name1 = name1u.encode('UTF-8')
1677
name2 = name2u.encode('UTF-8')
1678
expected_dirblocks = [
1680
[(name0, name0, 'file', './' + name0u),
1681
(name1, name1, 'directory', './' + name1u),
1682
(name2, name2, 'file', './' + name2u),
1685
((name1, './' + name1u),
1686
[(name1 + '/' + name0, name0, 'file', './' + name1u
1688
(name1 + '/' + name1, name1, 'directory', './' + name1u
1692
((name1 + '/' + name1, './' + name1u + '/' + name1u),
1697
return tree, expected_dirblocks
1699
def _filter_out(self, raw_dirblocks):
1700
"""Filter out a walkdirs_utf8 result.
1702
stat field is removed, all native paths are converted to unicode
1704
filtered_dirblocks = []
1705
for dirinfo, block in raw_dirblocks:
1706
dirinfo = (dirinfo[0], self._native_to_unicode(dirinfo[1]))
1709
details.append(line[0:3] + (self._native_to_unicode(line[4]), ))
1710
filtered_dirblocks.append((dirinfo, details))
1711
return filtered_dirblocks
1713
def test_walk_unicode_tree(self):
1714
self.requireFeature(tests.UnicodeFilenameFeature)
1715
tree, expected_dirblocks = self._get_unicode_tree()
1716
self.build_tree(tree)
1717
result = list(osutils._walkdirs_utf8('.'))
1718
self.assertEqual(expected_dirblocks, self._filter_out(result))
1720
def test_symlink(self):
1721
self.requireFeature(tests.SymlinkFeature)
1722
self.requireFeature(tests.UnicodeFilenameFeature)
1723
target = u'target\N{Euro Sign}'
1724
link_name = u'l\N{Euro Sign}nk'
1725
os.symlink(target, link_name)
1726
target_utf8 = target.encode('UTF-8')
1727
link_name_utf8 = link_name.encode('UTF-8')
1728
expected_dirblocks = [
1730
[(link_name_utf8, link_name_utf8,
1731
'symlink', './' + link_name),],
1733
result = list(osutils._walkdirs_utf8('.'))
1734
self.assertEqual(expected_dirblocks, self._filter_out(result))
1737
class TestReadLink(tests.TestCaseInTempDir):
1738
"""Exposes os.readlink() problems and the osutils solution.
1740
The only guarantee offered by os.readlink(), starting with 2.6, is that a
1741
unicode string will be returned if a unicode string is passed.
1743
But prior python versions failed to properly encode the passed unicode
1746
_test_needs_features = [tests.SymlinkFeature, tests.UnicodeFilenameFeature]
1749
super(tests.TestCaseInTempDir, self).setUp()
1750
self.link = u'l\N{Euro Sign}ink'
1751
self.target = u'targe\N{Euro Sign}t'
1752
os.symlink(self.target, self.link)
1754
def test_os_readlink_link_encoding(self):
1755
if sys.version_info < (2, 6):
1756
self.assertRaises(UnicodeEncodeError, os.readlink, self.link)
1758
self.assertEquals(self.target, os.readlink(self.link))
1760
def test_os_readlink_link_decoding(self):
1761
self.assertEquals(self.target.encode(osutils._fs_enc),
1762
os.readlink(self.link.encode(osutils._fs_enc)))