Rev 4937: (Martin <gz>) Change bb.test_non_ascii tests to skip earlier and use in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jan 7 00:59:21 GMT 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4937 [merge]
revision-id: pqm at pqm.ubuntu.com-20100107005919-3jl4nwntr1qgvtfl
parent: pqm at pqm.ubuntu.com-20100106204826-rehs7s23w0jbz6nj
parent: andrew.bennetts at canonical.com-20100106050656-zrx877eyg3aevh9w
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-01-07 00:59:19 +0000
message:
  (Martin <gz>) Change bb.test_non_ascii tests to skip earlier and use
  	addCleanup, as tearDown semantics have changed with testtools.
modified:
  bzrlib/tests/blackbox/test_non_ascii.py test_non_ascii.py-20060105214030-68010be784a5d854
=== modified file 'bzrlib/tests/blackbox/test_non_ascii.py'
--- a/bzrlib/tests/blackbox/test_non_ascii.py	2009-08-20 04:09:58 +0000
+++ b/bzrlib/tests/blackbox/test_non_ascii.py	2010-01-06 05:06:56 +0000
@@ -38,17 +38,15 @@
 
     def setUp(self):
         super(TestNonAscii, self).setUp()
-        self._orig_encoding = osutils._cached_user_encoding
+        self._check_can_encode_paths()
 
+        self.addCleanup(setattr, osutils, "_cached_user_encoding",
+            osutils._cached_user_encoding)
         osutils._cached_user_encoding = self.encoding
         email = self.info['committer'] + ' <joe at foo.com>'
         os.environ['BZR_EMAIL'] = email.encode(osutils.get_user_encoding())
         self.create_base()
 
-    def tearDown(self):
-        osutils._cached_user_encoding = self._orig_encoding
-        super(TestNonAscii, self).tearDown()
-
     def run_bzr_decode(self, args, encoding=None, fail=False, retcode=None,
                        working_dir=None):
         """Run bzr and decode the output into a particular encoding.
@@ -98,7 +96,7 @@
                     ' using encoding "%s"'
                     % (path, fs_enc))
 
-    def create_base(self):
+    def _check_can_encode_paths(self):
         fs_enc = osutils._fs_enc
         terminal_enc = osutils.get_terminal_encoding()
         fname = self.info['filename']
@@ -118,6 +116,7 @@
                     ' (even though it is valid in filesystem encoding "%s")'
                     % (thing, terminal_enc, fs_enc))
 
+    def create_base(self):
         wt = self.make_branch_and_tree('.')
         self.build_tree_contents([('a', 'foo\n')])
         wt.add('a')
@@ -128,6 +127,7 @@
         wt.add('b')
         wt.commit(self.info['message'])
 
+        fname = self.info['filename']
         self.build_tree_contents([(fname, 'unicode filename\n')])
         wt.add(fname)
         wt.commit(u'And a unicode file\n')




More information about the bazaar-commits mailing list