~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Parth Malwankar
  • Date: 2010-06-11 07:56:46 UTC
  • mto: This revision was merged to the branch mainline in revision 5303.
  • Revision ID: parth.malwankar@gmail.com-20100611075646-9yyeih46ken6yagd
fixed tests. closed review comments by mgz.

Show diffs side-by-side

added added

removed removed

Lines of Context:
184
184
        shape = sorted(os.listdir('.'))
185
185
        self.assertEquals(['A', 'B'], shape)
186
186
 
187
 
    def test_rename_error(self):
188
 
        # We wrap os.rename to make it give an error including the filenames
189
 
        # https://bugs.launchpad.net/bzr/+bug/491763
190
 
        err = self.assertRaises(OSError, osutils.rename,
191
 
            'nonexistent', 'target')
192
 
        self.assertContainsString(str(err), 'nonexistent')
193
 
 
194
187
 
195
188
class TestRandChars(tests.TestCase):
196
189
 
1071
1064
        self.assertExpectedBlocks(expected_dirblocks[1:], result)
1072
1065
 
1073
1066
    def test_walkdirs_os_error(self):
1074
 
        # <https://bugs.edge.launchpad.net/bzr/+bug/338653>
 
1067
        # <https://bugs.launchpad.net/bzr/+bug/338653>
1075
1068
        # Pyrex readdir didn't raise useful messages if it had an error
1076
1069
        # reading the directory
1077
1070
        if sys.platform == 'win32':
1917
1910
 
1918
1911
class TestTerminalWidth(tests.TestCase):
1919
1912
 
 
1913
    def setUp(self):
 
1914
        tests.TestCase.setUp(self)
 
1915
        self._orig_terminal_size_state = osutils._terminal_size_state
 
1916
        self._orig_first_terminal_size = osutils._first_terminal_size
 
1917
        self.addCleanup(self.restore_osutils_globals)
 
1918
        osutils._terminal_size_state = 'no_data'
 
1919
        osutils._first_terminal_size = None
 
1920
 
 
1921
    def restore_osutils_globals(self):
 
1922
        osutils._terminal_size_state = self._orig_terminal_size_state
 
1923
        osutils._first_terminal_size = self._orig_first_terminal_size
 
1924
        
1920
1925
    def replace_stdout(self, new):
1921
1926
        self.overrideAttr(sys, 'stdout', new)
1922
1927
 
2018
2023
        self.assertEquals(self.path, 'test_file')
2019
2024
        self.assertEquals(self.uid, s.st_uid)
2020
2025
        self.assertEquals(self.gid, s.st_gid)
 
2026
 
 
2027
class TestGetuserUnicode(tests.TestCase):
 
2028
 
 
2029
    def test_ascii_user(self):
 
2030
        osutils.set_or_unset_env('LOGNAME', 'jrandom')
 
2031
        self.assertEqual(u'jrandom', osutils.getuser_unicode())
 
2032
 
 
2033
    def test_unicode_user(self):
 
2034
        ue = osutils.get_user_encoding()
 
2035
        osutils.set_or_unset_env('LOGNAME', u'jrandom\xb6'.encode(ue))
 
2036
        self.assertEqual(u'jrandom\xb6', osutils.getuser_unicode())