Rev 5016: Simplify some tests in per_workingtree/test_smart_add.py. in file:///home/vila/src/bzr/bugs/322767-dont-add-conflict-related-files/

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Feb 8 10:49:49 GMT 2010


At file:///home/vila/src/bzr/bugs/322767-dont-add-conflict-related-files/

------------------------------------------------------------
revno: 5016
revision-id: v.ladeuil+lp at free.fr-20100208104948-jylpbzqlqyg6we1e
parent: v.ladeuil+lp at free.fr-20100208100004-c7tsmoqyt13vfkx3
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 322767-dont-add-conflict-related-files
timestamp: Mon 2010-02-08 11:49:48 +0100
message:
  Simplify some tests in per_workingtree/test_smart_add.py.
-------------- next part --------------
=== modified file 'bzrlib/tests/per_workingtree/test_smart_add.py'
--- a/bzrlib/tests/per_workingtree/test_smart_add.py	2010-02-08 10:00:04 +0000
+++ b/bzrlib/tests/per_workingtree/test_smart_add.py	2010-02-08 10:49:48 +0000
@@ -28,6 +28,7 @@
     workingtree,
     )
 from bzrlib.tests import (
+    features,
     test_smart_add,
     per_workingtree,
     )
@@ -225,60 +226,43 @@
                          ], [(path, ie.file_id) for path, ie
                                 in wt.inventory.iter_entries()])
 
-    def make_unicode_containing_tree(self):
-        try:
-            self.build_tree([u'a\u030a'])
-        except UnicodeError:
-            raise tests.TestSkipped('Filesystem cannot create unicode filenames')
+
+class TestSmartAddTreeUnicode(per_workingtree.TestCaseWithWorkingTree):
+
+    _test_needs_features = [tests.UnicodeFilenameFeature]
+
+    def setUp(self):
+        super(TestSmartAddTreeUnicode, self).setUp()
+        self.build_tree([u'a\u030a'])
         self.wt = self.make_branch_and_tree('.')
+        self.overrideAttr(osutils, 'normalized_filename')
 
     def test_accessible_explicit(self):
-        self.make_unicode_containing_tree()
-        orig = osutils.normalized_filename
         osutils.normalized_filename = osutils._accessible_normalized_filename
-        try:
-            self.wt.smart_add([u'a\u030a'])
-            self.wt.lock_read()
-            self.addCleanup(self.wt.unlock)
-            self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
-                    [(path, ie.kind) for path,ie in
-                        self.wt.inventory.iter_entries()])
-        finally:
-            osutils.normalized_filename = orig
+        self.wt.smart_add([u'a\u030a'])
+        self.wt.lock_read()
+        self.addCleanup(self.wt.unlock)
+        self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
+                         [(path, ie.kind) for path,ie in
+                          self.wt.inventory.iter_entries()])
 
     def test_accessible_implicit(self):
-        self.make_unicode_containing_tree()
-        orig = osutils.normalized_filename
         osutils.normalized_filename = osutils._accessible_normalized_filename
-        try:
-            self.wt.smart_add([])
-            self.wt.lock_read()
-            self.addCleanup(self.wt.unlock)
-            self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
-                    [(path, ie.kind) for path,ie in
-                        self.wt.inventory.iter_entries()])
-        finally:
-            osutils.normalized_filename = orig
+        self.wt.smart_add([])
+        self.wt.lock_read()
+        self.addCleanup(self.wt.unlock)
+        self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
+                         [(path, ie.kind) for path,ie in
+                          self.wt.inventory.iter_entries()])
 
     def test_inaccessible_explicit(self):
-        self.make_unicode_containing_tree()
-        orig = osutils.normalized_filename
         osutils.normalized_filename = osutils._inaccessible_normalized_filename
-        try:
-            self.assertRaises(errors.InvalidNormalization,
-                    self.wt.smart_add, [u'a\u030a'])
-        finally:
-            osutils.normalized_filename = orig
+        self.assertRaises(errors.InvalidNormalization,
+                          self.wt.smart_add, [u'a\u030a'])
 
     def test_inaccessible_implicit(self):
-        self.make_unicode_containing_tree()
-        orig = osutils.normalized_filename
         osutils.normalized_filename = osutils._inaccessible_normalized_filename
-        try:
-            # TODO: jam 20060701 In the future, this should probably
-            #       just ignore files that don't fit the normalization
-            #       rules, rather than exploding
-            self.assertRaises(errors.InvalidNormalization,
-                    self.wt.smart_add, [])
-        finally:
-            osutils.normalized_filename = orig
+        # TODO: jam 20060701 In the future, this should probably
+        #       just ignore files that don't fit the normalization
+        #       rules, rather than exploding
+        self.assertRaises(errors.InvalidNormalization, self.wt.smart_add, [])



More information about the bazaar-commits mailing list