From 0b8a27e64e3cfb54686af11c5a4c6cc0874da618 Mon Sep 17 00:00:00 2001 From: Viktor Stanchev Date: Thu, 3 Sep 2015 22:46:06 -0700 Subject: [PATCH] test parse_cmd --- tests/test_pirate.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 tests/test_pirate.py diff --git a/tests/test_pirate.py b/tests/test_pirate.py new file mode 100755 index 0000000..dff36af --- /dev/null +++ b/tests/test_pirate.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +import unittest +import pirate.pirate + + +class TestPirate(unittest.TestCase): + + def test_parse_cmd(self): + tests = [ + [['abc', ''], ['abc']], + [['abc %s', 'url'], ['abc', 'url']], + [['abc "%s"', 'url'], ['abc', 'url']], + [["abc \'%s\'", 'url'], ['abc', 'url']], + [['abc bash -c "\'%s\'"', 'url'], ['abc', 'bash', '-c', "'url'"]], + [['abc %s %s', 'url'], ['abc', 'url', 'url']], + ] + for test in tests: + self.assertEqual(pirate.pirate.parse_cmd(*test[0]), test[1]) + +if __name__ == '__main__': + unittest.main()