Debian Codegraph @

test/units/utils/test_shlex.py

raw
1 # (c) 2015, Marius Gedminas <[email protected]>
2 #
3 # This file is part of Ansible
4 #
5 # Ansible is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Ansible is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
17
18 from __future__ import annotations
19
20 import unittest
21
22 from ansible.utils.shlex import shlex_split
23
24
25 class TestSplit(unittest.TestCase):
26
27 def test_trivial(self):
28 self.assertEqual(shlex_split("a b c"), ["a", "b", "c"])
29
30 def test_unicode(self):
31 self.assertEqual(shlex_split(u"a b \u010D"), [u"a", u"b", u"\u010D"])
32
33 def test_quoted(self):
34 self.assertEqual(shlex_split('"a b" c'), ["a b", "c"])
35
36 def test_comments(self):
37 self.assertEqual(shlex_split('"a b" c # d', comments=True), ["a b", "c"])
38
39 def test_error(self):
40 self.assertRaises(ValueError, shlex_split, 'a "b')