Rev 4791: Split the win32 globbing tests up a bit. in http://bazaar.launchpad.net/~jameinel/bzr/2.1.0b3-glob-updates

John Arbash Meinel john at arbash-meinel.com
Sun Nov 8 00:19:43 GMT 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.1.0b3-glob-updates

------------------------------------------------------------
revno: 4791
revision-id: john at arbash-meinel.com-20091108001935-qix40x4c4hyqx3e5
parent: john at arbash-meinel.com-20091108000526-33vvx9svs5acs38x
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1.0b3-glob-updates
timestamp: Sat 2009-11-07 18:19:35 -0600
message:
  Split the win32 globbing tests up a bit.
  
  They were testing both that case-insensitive globbing worked
  for 'A*' matching 'a1', and that '/' was supported as a 
  directory separator. Which doesn't apply on all platforms.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_win32utils.py'
--- a/bzrlib/tests/test_win32utils.py	2009-11-08 00:05:26 +0000
+++ b/bzrlib/tests/test_win32utils.py	2009-11-08 00:19:35 +0000
@@ -69,22 +69,28 @@
             [['*'], ['*']],
             [['a', 'a'], ['a', 'a']]])
 
-    def test_tree_ascii(self):
-        """Checks the glob expansion and path separation char
-        normalization"""
+    def build_ascii_tree(self):
         self.build_tree(['a', 'a1', 'a2', 'a11', 'a.1',
                          'b', 'b1', 'b2', 'b3',
                          'c/', 'c/c1', 'c/c2',
                          'd/', 'd/d1', 'd/d2', 'd/e/', 'd/e/e1'])
+
+    def build_unicode_tree(self):
+        self.requireFeature(UnicodeFilenameFeature)
+        self.build_tree([u'\u1234', u'\u1234\u1234', u'\u1235/',
+                         u'\u1235/\u1235'])
+
+    def test_tree_ascii(self):
+        """Checks the glob expansion and path separation char
+        normalization"""
+        self.build_ascii_tree()
         self._run_testset([
             # no wildcards
             [[u'a'], [u'a']],
             [[u'a', u'a' ], [u'a', u'a']],
-            [[u'A'], [u'A']],
 
             [[u'd'], [u'd']],
             [[u'd/'], [u'd/']],
-            [[u'd\\'], [u'd/']],
 
             # wildcards
             [[u'a*'], [u'a', u'a1', u'a2', u'a11', u'a.1']],
@@ -92,20 +98,39 @@
             [[u'a?'], [u'a1', u'a2']],
             [[u'a??'], [u'a11', u'a.1']],
             [[u'b[1-2]'], [u'b1', u'b2']],
-            [[u'A?'], [u'a1', u'a2']],
 
             [[u'd/*'], [u'd/d1', u'd/d2', u'd/e']],
+            [[u'?/*'], [u'c/c1', u'c/c2', u'd/d1', u'd/d2', u'd/e']],
+            [[u'*/*'], [u'c/c1', u'c/c2', u'd/d1', u'd/d2', u'd/e']],
+            [[u'*/'], [u'c/', u'd/']],
+            ])
+
+    def test_backslash_globbing(self):
+        self.build_ascii_tree()
+        try:
+            os.lstat('d\\d2')
+        except OSError:
+            raise tests.TestNotApplicable("filesystem doesn't treat"
+                " \\ as a directory separator")
+        self._run_testset([
+            [[u'd\\'], [u'd/']],
             [[u'd\\*'], [u'd/d1', u'd/d2', u'd/e']],
             [[u'?\\*'], [u'c/c1', u'c/c2', u'd/d1', u'd/d2', u'd/e']],
             [[u'*\\*'], [u'c/c1', u'c/c2', u'd/d1', u'd/d2', u'd/e']],
-            [[u'*/'], [u'c/', u'd/']],
-            [[u'*\\'], [u'c/', u'd/']]])
+            [[u'*\\'], [u'c/', u'd/']],
+            ])
+
+    def test_case_insensitive_globbing(self):
+        self.requireFeature(tests.CaseInsensitiveFilesystemFeature)
+        self.build_ascii_tree()
+        self._run_testset([
+            [[u'A'], [u'A']],
+            [[u'A?'], [u'a1', u'a2']],
+            ])
 
     def test_tree_unicode(self):
         """Checks behaviour with non-ascii filenames"""
-        self.requireFeature(UnicodeFilenameFeature)
-        self.build_tree([u'\u1234', u'\u1234\u1234', u'\u1235/',
-                         u'\u1235/\u1235'])
+        self.build_unicode_tree()
         self._run_testset([
             # no wildcards
             [[u'\u1234'], [u'\u1234']],
@@ -121,16 +146,30 @@
 
             [[u'\u1235/?'], [u'\u1235/\u1235']],
             [[u'\u1235/*'], [u'\u1235/\u1235']],
+            [[u'?/'], [u'\u1235/']],
+            [[u'*/'], [u'\u1235/']],
+            [[u'?/?'], [u'\u1235/\u1235']],
+            [[u'*/*'], [u'\u1235/\u1235']],
+            ])
+
+    def test_unicode_backslashes(self):
+        self.build_unicode_tree()
+        try:
+            os.lstat('\u1235\\\u1235')
+        except OSError:
+            raise tests.TestNotApplicable("filesystem doesn't treat"
+                " \\ as a directory separator")
+        self._run_testset([
+            # no wildcards
+            [[u'\u1235\\'], [u'\u1235\\']],
+            [[u'\u1235\\\u1235'], [u'\u1235\\\u1235']],
             [[u'\u1235\\?'], [u'\u1235/\u1235']],
             [[u'\u1235\\*'], [u'\u1235/\u1235']],
-            [[u'?/'], [u'\u1235/']],
-            [[u'*/'], [u'\u1235/']],
             [[u'?\\'], [u'\u1235/']],
             [[u'*\\'], [u'\u1235/']],
-            [[u'?/?'], [u'\u1235/\u1235']],
-            [[u'*/*'], [u'\u1235/\u1235']],
             [[u'?\\?'], [u'\u1235/\u1235']],
-            [[u'*\\*'], [u'\u1235/\u1235']]])
+            [[u'*\\*'], [u'\u1235/\u1235']],
+            ])
 
     def _run_testset(self, testset):
         for pattern, expected in testset:



More information about the bazaar-commits mailing list