From ffcaa20e17283b23d6334b8a5039380571734cfb Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sun, 5 Nov 2017 17:51:05 +0000 Subject: add test for argparse validator --- tests/utils/argparse_test.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/utils') diff --git a/tests/utils/argparse_test.py b/tests/utils/argparse_test.py index 91f8a3f4..ff339b26 100644 --- a/tests/utils/argparse_test.py +++ b/tests/utils/argparse_test.py @@ -163,3 +163,18 @@ class TestOptionalFileLike(unittest.TestCase): path = os.path.join(d, 'fifo') os.mkfifo(path) cargparse.optional_file_like(path) + + +class TestIntOrPlusOrMinus(unittest.TestCase): + """Tests for the is_int_or_pm validator.""" + + def test_int(self): + self.assertTrue(cargparse.is_int_or_pm('5')) + + def test_pm(self): + self.assertTrue(cargparse.is_int_or_pm('+')) + self.assertTrue(cargparse.is_int_or_pm('-')) + + def test_rubbish(self): + with self.assertRaises(cargparse.ValidationFailed): + cargparse.is_int_or_pm('XX') -- cgit v1.2.3