Пример #1
0
    def test_command_with_backquotes(self):
        story = """
$ foo = `bzr file-id toto`
"""
        self.assertEqual([(['foo', '=', '`bzr file-id toto`'],
                            None, None, None)],
                          script._script_to_commands(story))
Пример #2
0
    def test_command_with_backquotes(self):
        story = """
$ foo = `bzr file-id toto`
"""
        self.assertEquals([(['foo', '=', '`bzr file-id toto`'],
                            None, None, None)],
                          script._script_to_commands(story))
Пример #3
0
    def test_command_with_error(self):
        story = """
$ bzr branch foo
2>bzr: ERROR: Not a branch: "foo"
"""
        self.assertEquals([(['bzr', 'branch', 'foo'],
                            None, None, 'bzr: ERROR: Not a branch: "foo"\n')],
                          script._script_to_commands(story))
Пример #4
0
    def test_command_with_error(self):
        story = """
$ bzr branch foo
2>bzr: ERROR: Not a branch: "foo"
"""
        self.assertEqual([(['bzr', 'branch', 'foo'],
                            None, None, 'bzr: ERROR: Not a branch: "foo"\n')],
                          script._script_to_commands(story))
Пример #5
0
    def test_command_with_output(self):
        story = """
$ bzr add
adding file
adding file2
"""
        self.assertEqual([(['bzr', 'add'], None,
                            'adding file\nadding file2\n', None)],
                          script._script_to_commands(story))
Пример #6
0
    def test_command_with_output(self):
        story = """
$ bzr add
adding file
adding file2
"""
        self.assertEquals([(['bzr', 'add'], None,
                            'adding file\nadding file2\n', None)],
                          script._script_to_commands(story))
Пример #7
0
 def test_comment_multiple_lines(self):
     self.assertEqual([
         (['bar'], None, None, None),
         ],
         script._script_to_commands("""
         # this comment is ignored
         # so is this
         # no we run bar
         $ bar
         """))
Пример #8
0
 def test_comment_multiple_lines(self):
     self.assertEquals([
         (['bar'], None, None, None),
         ],
         script._script_to_commands("""
         # this comment is ignored
         # so is this
         # no we run bar
         $ bar
         """))
Пример #9
0
 def test_indented(self):
     # scripts are commonly given indented within the test source code, and
     # common indentation is stripped off
     story = """
         $ bzr add
         adding file
         adding file2
         """
     self.assertEqual([(['bzr', 'add'], None,
                         'adding file\nadding file2\n', None)],
                       script._script_to_commands(story))
Пример #10
0
 def test_indented(self):
     # scripts are commonly given indented within the test source code, and
     # common indentation is stripped off
     story = """
         $ bzr add
         adding file
         adding file2
         """
     self.assertEquals([(['bzr', 'add'], None,
                         'adding file\nadding file2\n', None)],
                       script._script_to_commands(story))
Пример #11
0
    def test_trim_blank_lines(self):
        """Blank lines are respected, but trimmed at the start and end.

        Python triple-quoted syntax is going to give stubby/empty blank lines 
        right at the start and the end.  These are cut off so that callers don't 
        need special syntax to avoid them.

        However we do want to be able to match commands that emit blank lines.
        """
        self.assertEqual([
            (['bar'], None, '\n', None),
            ],
            script._script_to_commands("""
            $bar

            """))
Пример #12
0
    def test_trim_blank_lines(self):
        """Blank lines are respected, but trimmed at the start and end.

        Python triple-quoted syntax is going to give stubby/empty blank lines 
        right at the start and the end.  These are cut off so that callers don't 
        need special syntax to avoid them.

        However we do want to be able to match commands that emit blank lines.
        """
        self.assertEquals([
            (['bar'], None, '\n', None),
            ],
            script._script_to_commands("""
            $bar

            """))
Пример #13
0
 def test_comment_is_ignored(self):
     self.assertEquals([], script._script_to_commands('#comment\n'))
Пример #14
0
 def test_command_with_single_quoted_param(self):
     story = """$ bzr commit -m 'two words'"""
     self.assertEqual([(['bzr', 'commit', '-m', "'two words'"],
                         None, None, None)],
                        script._script_to_commands(story))
Пример #15
0
 def test_command_with_input(self):
     self.assertEquals(
         [(['cat', '>file'], 'content\n', None, None)],
         script._script_to_commands('$ cat >file\n<content\n'))
Пример #16
0
 def test_command_with_double_quoted_param(self):
     story = """$ bzr commit -m "two words" """
     self.assertEquals([(['bzr', 'commit', '-m', '"two words"'],
                         None, None, None)],
                        script._script_to_commands(story))
Пример #17
0
 def test_command_with_single_quoted_param(self):
     story = """$ bzr commit -m 'two words'"""
     self.assertEquals([(['bzr', 'commit', '-m', "'two words'"],
                         None, None, None)],
                        script._script_to_commands(story))
Пример #18
0
 def test_simple_command(self):
     self.assertEquals([(['cd', 'trunk'], None, None, None)],
                        script._script_to_commands('$ cd trunk'))
Пример #19
0
 def test_command_with_double_quoted_param(self):
     story = """$ bzr commit -m "two words" """
     self.assertEqual([(['bzr', 'commit', '-m', '"two words"'],
                         None, None, None)],
                        script._script_to_commands(story))
Пример #20
0
 def test_simple_command(self):
     self.assertEqual([(['cd', 'trunk'], None, None, None)],
                        script._script_to_commands('$ cd trunk'))
Пример #21
0
 def test_comment_is_ignored(self):
     self.assertEqual([], script._script_to_commands('#comment\n'))
Пример #22
0
 def test_command_with_input(self):
     self.assertEqual(
         [(['cat', '>file'], 'content\n', None, None)],
         script._script_to_commands('$ cat >file\n<content\n'))