summaryrefslogtreecommitdiff
path: root/Lib/test/test_argparse.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r--Lib/test/test_argparse.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index 9d68f40571..bcf2cc9b26 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -1619,6 +1619,24 @@ class TestFileTypeOpenArgs(TestCase):
m.assert_called_with('foo', *args)
+class TestFileTypeMissingInitialization(TestCase):
+ """
+ Test that add_argument throws an error if FileType class
+ object was passed instead of instance of FileType
+ """
+
+ def test(self):
+ parser = argparse.ArgumentParser()
+ with self.assertRaises(ValueError) as cm:
+ parser.add_argument('-x', type=argparse.FileType)
+
+ self.assertEqual(
+ '%r is a FileType class object, instance of it must be passed'
+ % (argparse.FileType,),
+ str(cm.exception)
+ )
+
+
class TestTypeCallable(ParserTestCase):
"""Test some callables as option/argument types"""