Beispiel #1
0
    def test_replace_arguments_invalid_quote(self):
        """Testing replace_arguments with invalid quotes in POSIX and non-POSIX
        mode raises an error
        """
        self.assertRaises(ValueError,
                          lambda: replace_arguments('"foo', [], posix=True))

        self.assertRaises(ValueError,
                          lambda: replace_arguments('"foo', [], posix=False))
Beispiel #2
0
 def test_replace_arguments_star_whitespace(self):
     """Testing replace_arguments with the special $* variable with
     whitespace-containing arguments
     """
     self.assertEqual(
         replace_arguments('$*', ['a', 'b', 'c d e'], posix=True),
         ['a', 'b', 'c d e'])
Beispiel #3
0
 def test_replace_arguments_quoted_non_posix(self):
     """Testing replace_arguments in non-POSIX mode with a quoted sequence
     in the command
     """
     self.assertEqual(
         replace_arguments("find . -iname '*.pyc' -delete", [],
                           posix=False),
         ['find', '.', '-iname', "'*.pyc'", '-delete'])
Beispiel #4
0
    def _replace_arguments(self, cmd, args):
        """Convenience method to return a list instead of generator.

        This allows us to compare with self.assertEqual to another list.
        """
        return list(aliases.replace_arguments(cmd, args))
Beispiel #5
0
    def _replace_arguments(self, cmd, args):
        """Convenience method to return a list instead of generator.

        This allows us to compare with self.assertEqual to another list.
        """
        return list(aliases.replace_arguments(cmd, args))
Beispiel #6
0
 def test_replace_arguments_escaped_posix(self):
     """Testing replace_arguments in POSIX mode evaluates escape sequences
     """
     self.assertEqual(
         replace_arguments(r'$1 \\ "\\" "\""', ['a'], posix=True),
         ['a', '\\', '\\', '"'])
Beispiel #7
0
 def test_replace_arguments_invalid_quote_non_posix(self):
     """Testing replace_arguments with escaped ending quote in POSIX mode
     raises an error
     """
     self.assertRaises(ValueError,
                       lambda: replace_arguments('"\\"', [], posix=True))
Beispiel #8
0
 def test_replace_arguments_invalid_quote_posix(self):
     """Testing replace_arguments with escaped ending quote in non-POSIX
     mode does not escape the quote
     """
     self.assertEqual(replace_arguments('"\\"', [], posix=False), ['"\\"'])
Beispiel #9
0
 def test_replace_arguments_unescaped_non_posix(self):
     """Testing replace_arguments in non-POSIX mode does not evaluate escape
     sequences
     """
     self.assertEqual(replace_arguments(r'"$1 \\"', ['a'], posix=False),
                      [r'"a \\"'])
Beispiel #10
0
 def test_replace_arguments_star(self):
     """Testing replace_arguments with the special $* variable"""
     self.assertEqual(replace_arguments('$*', ['a', 'b', 'c'], posix=True),
                      ['a', 'b', 'c'])
Beispiel #11
0
 def test_replace_arguments_unrecognized_variables(self):
     """Testing replace_arguments with an unrecognized variable name"""
     self.assertEqual(replace_arguments('$1 $test', ['f'], posix=True),
                      ['f', '$test'])
Beispiel #12
0
 def test_replace_arguments_append(self):
     """Testing replace_arguments with no variables or arguments."""
     self.assertEqual(
         replace_arguments('echo', ['a', 'b', 'c'], posix=True),
         ['echo', 'a', 'b', 'c'])
Beispiel #13
0
 def test_replace_arguments_blank(self):
     """Testing replace_arguments with variables and a missing argument"""
     self.assertEqual(replace_arguments('rbt post $1', [], posix=True),
                      ['rbt', 'post'])
Beispiel #14
0
 def test_replace_arguments_multiple(self):
     """Testing replace_arguments with multiple variables and arguments"""
     self.assertEqual(replace_arguments('$1..$2', ['a', 'b'], posix=True),
                      ['a..b'])
Beispiel #15
0
 def test_replace_arguments_basic(self):
     """Testing replace_arguments with variables and arguments"""
     self.assertEqual(replace_arguments('$1', ['HEAD'], posix=True),
                      ['HEAD'])