~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_script.py

Handle simple, double and back quotes.

* bzrlib/tests/test_script.py:
(TestScriptSyntax): Add quote tests.

* bzrlib/tests/script.py:
(split): Encapsulate the split to better control which quotes are
kept in the parameters.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from bzrlib.tests import script
21
21
 
22
22
 
23
 
class TestUserTest(tests.TestCase):
 
23
class TestScriptSyntax(tests.TestCase):
24
24
 
25
25
    def test_comment_is_ignored(self):
26
26
        self.assertEquals([], script._script_to_commands('#comment\n'))
32
32
        self.assertEquals([(['cd', 'trunk'], None, None)],
33
33
                           script._script_to_commands('cd trunk'))
34
34
 
 
35
    def test_command_with_single_quoted_param(self):
 
36
        story = """bzr commit -m 'two words'"""
 
37
        self.assertEquals([(['bzr', 'commit', '-m', 'two words'], None, None)],
 
38
                           script._script_to_commands(story))
 
39
 
 
40
    def test_command_with_double_quoted_param(self):
 
41
        story = """bzr commit -m "two words" """
 
42
        self.assertEquals([(['bzr', 'commit', '-m', 'two words'], None, None)],
 
43
                           script._script_to_commands(story))
 
44
 
35
45
    def test_command_with_input(self):
36
46
        self.assertEquals([(['cat', '>file'], ['content\n'], None)],
37
47
                           script._script_to_commands('cat >file\n<content\n'))
50
60
    def test_output_without_command(self):
51
61
        self.assertRaises(SyntaxError, script._script_to_commands, '>input')
52
62
 
53
 
    # FIXME: not passing yet.
54
 
    def xtest_command_with_backquotes(self):
 
63
    def test_command_with_backquotes(self):
55
64
        story = """
56
65
foo = `bzr file-id toto`
57
66
"""