summaryrefslogtreecommitdiff
path: root/tests/utils
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2017-11-05 17:51:05 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2017-11-08 18:27:48 +0000
commitffcaa20e17283b23d6334b8a5039380571734cfb (patch)
treebcf22fd84081a72760e3497c8d48e6b4ac988821 /tests/utils
parent87225c353689f226fe0128b84ee60dd138c1bba2 (diff)
add test for argparse validator
Diffstat (limited to 'tests/utils')
-rw-r--r--tests/utils/argparse_test.py15
1 files changed, 15 insertions, 0 deletions
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')