~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: John Arbash Meinel
  • Date: 2010-11-05 20:54:32 UTC
  • mfrom: (5526 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5527.
  • Revision ID: john@arbash-meinel.com-20101105205432-rmyozu8sthyhmri8
Merge bzr.dev to resolve bzr-2.3.txt (aka NEWS)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2085
2085
        encoded_username = uni_username.encode(ue)
2086
2086
        osutils.set_or_unset_env('LOGNAME', encoded_username)
2087
2087
        self.assertEqual(uni_username, osutils.getuser_unicode())
 
2088
        osutils.set_or_unset_env('LOGNAME', u'jrandom\xb6'.encode(ue))
 
2089
        self.assertEqual(u'jrandom\xb6', osutils.getuser_unicode())
 
2090
 
 
2091
class TestBackupNames(tests.TestCase):
 
2092
 
 
2093
    def setUp(self):
 
2094
        super(TestBackupNames, self).setUp()
 
2095
        self.backups = []
 
2096
 
 
2097
    def backup_exists(self, name):
 
2098
        return name in self.backups
 
2099
 
 
2100
    def available_backup_name(self, name):
 
2101
        backup_name = osutils.available_backup_name(name, self.backup_exists)
 
2102
        self.backups.append(backup_name)
 
2103
        return backup_name
 
2104
 
 
2105
    def assertBackupName(self, expected, name):
 
2106
        self.assertEqual(expected, self.available_backup_name(name))
 
2107
 
 
2108
    def test_empty(self):
 
2109
        self.assertBackupName('file.~1~', 'file')
 
2110
 
 
2111
    def test_existing(self):
 
2112
        self.available_backup_name('file')
 
2113
        self.available_backup_name('file')
 
2114
        self.assertBackupName('file.~3~', 'file')
 
2115
        # Empty slots are found, this is not a strict requirement and may be
 
2116
        # revisited if we test against all implementations.
 
2117
        self.backups.remove('file.~2~')
 
2118
        self.assertBackupName('file.~2~', 'file')