Rev 6422: (gz) Fix bt.test_osutils and bt.test_config windows fallout from recent in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jan 4 17:06:02 UTC 2012


At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 6422 [merge]
revision-id: pqm at pqm.ubuntu.com-20120104170602-ut82c4nbvn63nj3m
parent: pqm at pqm.ubuntu.com-20120103174403-a1g6m9e6m95515uk
parent: martin.packman at canonical.com-20120104113556-l4l5z81gjj3wpy98
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2012-01-04 17:06:02 +0000
message:
  (gz) Fix bt.test_osutils and bt.test_config windows fallout from recent
   changes (Martin Packman)
modified:
  bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
  bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2012-01-03 12:56:06 +0000
+++ b/bzrlib/tests/test_config.py	2012-01-04 11:09:24 +0000
@@ -3017,7 +3017,7 @@
         stack = config.Stack([store.get_sections], store)
         stack.set('foo', ' a b c ')
         store.save()
-        self.assertFileEqual('foo = " a b c "\n', 'foo.conf')
+        self.assertFileEqual('foo = " a b c "' + os.linesep, 'foo.conf')
 
 
 class TestTransportIniFileStore(TestStore):

=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py	2011-12-14 19:31:25 +0000
+++ b/bzrlib/tests/test_osutils.py	2012-01-04 11:35:56 +0000
@@ -2097,8 +2097,19 @@
 
 class TestGetuserUnicode(tests.TestCase):
 
+    def test_is_unicode(self):
+        user = osutils.getuser_unicode()
+        self.assertIsInstance(user, unicode)
+
+    def envvar_to_override(self):
+        if sys.platform == "win32":
+            # Disable use of platform calls on windows so envvar is used
+            self.overrideAttr(win32utils, 'has_ctypes', False)
+            return 'USERNAME' # only variable used on windows
+        return 'LOGNAME' # first variable checked by getpass.getuser()
+
     def test_ascii_user(self):
-        self.overrideEnv('LOGNAME', 'jrandom')
+        self.overrideEnv(self.envvar_to_override(), 'jrandom')
         self.assertEqual(u'jrandom', osutils.getuser_unicode())
 
     def test_unicode_user(self):
@@ -2110,10 +2121,8 @@
                 % (osutils.get_user_encoding(),))
         uni_username = u'jrandom' + uni_val
         encoded_username = uni_username.encode(ue)
-        self.overrideEnv('LOGNAME', encoded_username)
+        self.overrideEnv(self.envvar_to_override(), encoded_username)
         self.assertEqual(uni_username, osutils.getuser_unicode())
-        self.overrideEnv('LOGNAME', u'jrandom\xb6'.encode(ue))
-        self.assertEqual(u'jrandom\xb6', osutils.getuser_unicode())
 
 
 class TestBackupNames(tests.TestCase):




More information about the bazaar-commits mailing list