/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_win32utils.py

  • Committer: Kuno Meyer
  • Date: 2007-07-13 22:01:17 UTC
  • mto: This revision was merged to the branch mainline in revision 2655.
  • Revision ID: kuno.meyer@gmx.ch-20070713220117-vwei142086q2ophm
justĀ reformatting

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
from bzrlib.tests import TestCaseInTempDir
 
17
from bzrlib.tests import TestCaseInTempDir, TestSkipped
18
18
from bzrlib.win32utils import glob_expand
 
19
import sys
19
20
 
20
21
 
21
22
class Win32UtilsGlobExpand(TestCaseInTempDir):
 
23
 
 
24
    def setUp(self):
 
25
        super(Win32UtilsGlobExpand, self).setUp()
 
26
        if sys.platform != 'win32':
 
27
             raise TestSkipped('just for the Win32 platform')
22
28
   
23
29
    def test_empty_tree(self):
24
30
        self.build_tree([])
25
 
        
26
 
        testset = [[['a'], ['a']],
27
 
                   [['?'], ['?']],
28
 
                   [['*'], ['*']],
29
 
                   [['a', 'a'], ['a', 'a']]]
30
 
                   
31
 
        self._run_testset(testset)
 
31
        self._run_testset([
 
32
            [['a'], ['a']],
 
33
            [['?'], ['?']],
 
34
            [['*'], ['*']],
 
35
            [['a', 'a'], ['a', 'a']]])
32
36
        
33
37
    def test_tree1(self):
34
38
        self.build_tree(['a', 'a1', 'a2', 'a11', 'a.1',
35
39
                         'b', 'b1', 'b2', 'b3',
36
40
                         'c/', 'c/c1', 'c/c2', 
37
41
                         'd/', 'd/d1', 'd/d2'])
 
42
        self._run_testset([
 
43
            # no wildcards
 
44
            [['a'], ['a']],
 
45
            [['a', 'a' ], ['a', 'a']],
 
46
            [['A'], ['A']],
 
47
                
 
48
            [['d'], ['d']],
 
49
            [['d/'], ['d/']],
 
50
            [['d\\'], ['d\\']],
 
51
               
 
52
            # wildcards
 
53
            [['a*'], ['a', 'a1', 'a2', 'a11', 'a.1']],
 
54
            [['?'], ['a', 'b', 'c', 'd']],
 
55
            [['a?'], ['a1', 'a2']],
 
56
            [['a??'], ['a11', 'a.1']],
 
57
            [['b[1-2]'], ['b1', 'b2']],
 
58
            [['A?'], ['a1', 'a2']],
 
59
               
 
60
            [['d/*'], ['d\\d1', 'd\\d2']],
 
61
            [['d\\*'], ['d\\d1', 'd\\d2']],
 
62
            [['?\\*'], ['c\\c1', 'c\\c2', 'd\\d1', 'd\\d2']],
 
63
            [['*\\*'], ['c\\c1', 'c\\c2', 'd\\d1', 'd\\d2']],
 
64
            [['*/'], ['c\\', 'd\\']],
 
65
            [['*\\'], ['c\\', 'd\\']]])
38
66
        
39
 
        testset = [# no wildcards
40
 
                   [['a'], ['a']],
41
 
                   [['a', 'a' ], ['a', 'a']],
42
 
                   [['A'], ['A']],
43
 
 
44
 
                   [['d'], ['d']],
45
 
                   [['d/'], ['d/']],
46
 
                   [['d\\'], ['d\\']],
47
 
                   
48
 
                   # wildcards
49
 
                   [['a*'], ['a', 'a1', 'a2', 'a11', 'a.1']],
50
 
                   [['?'], ['a', 'b', 'c', 'd']],
51
 
                   [['a?'], ['a1', 'a2']],
52
 
                   [['a??'], ['a11', 'a.1']],
53
 
                   [['b[1-2]'], ['b1', 'b2']],
54
 
                   [['A?'], ['a1', 'a2']],
55
 
                   
56
 
                   [['d/*'], ['d\\d1', 'd\\d2']],
57
 
                   [['d\\*'], ['d\\d1', 'd\\d2']],
58
 
                   [['?\\*'], ['c\\c1', 'c\\c2', 'd\\d1', 'd\\d2']],
59
 
                   [['*\\*'], ['c\\c1', 'c\\c2', 'd\\d1', 'd\\d2']],
60
 
                   [['*/'], ['c\\', 'd\\']],
61
 
                   [['*\\'], ['c\\', 'd\\']]]
62
 
 
63
 
        self._run_testset(testset)                   
64
 
                      
65
67
    def _run_testset(self, testset):
66
68
        for pattern, expected in testset:
67
69
            result = glob_expand(pattern)
68
70
            expected.sort()
69
71
            result.sort()
70
72
            self.assertEqual(expected, result, 'pattern %s' % pattern)
71
 
        
 
73