/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_cmdline.py

  • Committer: Robert Collins
  • Date: 2010-05-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
from .. import (
 
18
from bzrlib import (
19
19
    cmdline,
20
 
    tests,
21
 
    )
22
 
from .features import backslashdir_feature
23
 
 
 
20
    tests)
24
21
 
25
22
class TestSplitter(tests.TestCase):
26
23
 
43
40
 
44
41
    def test_posix_quotations(self):
45
42
        self.assertAsTokens([(True, u'foo bar')], u"'foo bar'",
46
 
                            single_quotes_allowed=True)
 
43
            single_quotes_allowed=True)
47
44
        self.assertAsTokens([(True, u'foo bar')], u"'fo''o b''ar'",
48
 
                            single_quotes_allowed=True)
 
45
            single_quotes_allowed=True)
49
46
        self.assertAsTokens([(True, u'foo bar')], u'"fo""o b""ar"',
50
 
                            single_quotes_allowed=True)
 
47
            single_quotes_allowed=True)
51
48
        self.assertAsTokens([(True, u'foo bar')], u'"fo"\'o b\'"ar"',
52
 
                            single_quotes_allowed=True)
 
49
            single_quotes_allowed=True)
53
50
 
54
51
    def test_nested_quotations(self):
55
52
        self.assertAsTokens([(True, u'foo"" bar')], u"\"foo\\\"\\\" bar\"")
56
53
        self.assertAsTokens([(True, u'foo\'\' bar')], u"\"foo'' bar\"")
57
54
        self.assertAsTokens([(True, u'foo\'\' bar')], u"\"foo'' bar\"",
58
 
                            single_quotes_allowed=True)
 
55
            single_quotes_allowed=True)
59
56
        self.assertAsTokens([(True, u'foo"" bar')], u"'foo\"\" bar'",
60
 
                            single_quotes_allowed=True)
 
57
            single_quotes_allowed=True)
61
58
 
62
59
    def test_empty_result(self):
63
60
        self.assertAsTokens([], u'')
67
64
        self.assertAsTokens([(True, '')], u'""')
68
65
        self.assertAsTokens([(False, u"''")], u"''")
69
66
        self.assertAsTokens([(True, '')], u"''", single_quotes_allowed=True)
70
 
        self.assertAsTokens([(False, u'a'), (True, u''), (False, u'c')],
71
 
                            u'a "" c')
72
 
        self.assertAsTokens([(False, u'a'), (True, u''), (False, u'c')],
73
 
                            u"a '' c", single_quotes_allowed=True)
74
67
 
75
68
    def test_unicode_chars(self):
76
69
        self.assertAsTokens([(False, u'f\xb5\xee'), (False, u'\u1234\u3456')],
77
 
                            u'f\xb5\xee \u1234\u3456')
 
70
                             u'f\xb5\xee \u1234\u3456')
78
71
 
79
72
    def test_newline_in_quoted_section(self):
80
73
        self.assertAsTokens([(True, u'foo\nbar\nbaz\n')], u'"foo\nbar\nbaz\n"')
81
74
        self.assertAsTokens([(True, u'foo\nbar\nbaz\n')], u"'foo\nbar\nbaz\n'",
82
 
                            single_quotes_allowed=True)
 
75
            single_quotes_allowed=True)
83
76
 
84
77
    def test_escape_chars(self):
85
78
        self.assertAsTokens([(False, u'foo\\bar')], u'foo\\bar')
95
88
 
96
89
    def test_multiple_quoted_args(self):
97
90
        self.assertAsTokens([(True, u'x x'), (True, u'y y')],
98
 
                            u'"x x" "y y"')
 
91
            u'"x x" "y y"')
99
92
        self.assertAsTokens([(True, u'x x'), (True, u'y y')],
100
 
                            u'"x x" \'y y\'', single_quotes_allowed=True)
101
 
 
102
 
    def test_n_backslashes_handling(self):
103
 
        # https://bugs.launchpad.net/bzr/+bug/528944
104
 
        # actually we care about the doubled backslashes when they're
105
 
        # represents UNC paths.
106
 
        # But in fact there is too much weird corner cases
107
 
        # (see https://bugs.launchpad.net/tortoisebzr/+bug/569050)
108
 
        # so to reproduce every bit of windows command-line handling
109
 
        # could be not worth of efforts?
110
 
        self.requireFeature(backslashdir_feature)
111
 
        self.assertAsTokens([(True, r'\\host\path')], r'"\\host\path"')
112
 
        self.assertAsTokens([(False, r'\\host\path')], r'\\host\path')
113
 
        # handling of " after the 2n and 2n+1 backslashes
114
 
        # inside and outside the quoted string
115
 
        self.assertAsTokens([(True, r'\\'), (False, r'*.py')], r'"\\\\" *.py')
116
 
        self.assertAsTokens([(True, r'\\" *.py')], r'"\\\\\" *.py"')
117
 
        self.assertAsTokens([(True, r'\\ *.py')], r'\\\\" *.py"')
118
 
        self.assertAsTokens([(False, r'\\"'), (False, r'*.py')],
119
 
                            r'\\\\\" *.py')
120
 
        self.assertAsTokens([(True, u'\\\\')], u'"\\\\')
 
93
            u'"x x" \'y y\'', single_quotes_allowed=True)