summaryrefslogtreecommitdiff
path: root/test/test_argparse.py
diff options
context:
space:
mode:
authorsteven.bethard <devnull@localhost>2009-09-12 16:08:15 +0000
committersteven.bethard <devnull@localhost>2009-09-12 16:08:15 +0000
commit660f1071cf765cdcebb6675a1ce5f0f925cbcb3a (patch)
treededffe5f56111fd4b8d8831a1213e32f70b4c3ca /test/test_argparse.py
parent731583b6079d863789ee79bb60481b88c4165a74 (diff)
downloadargparse-660f1071cf765cdcebb6675a1ce5f0f925cbcb3a.tar.gz
Fix bug where classic classes were being rejected as type= arguments.
Diffstat (limited to 'test/test_argparse.py')
-rw-r--r--test/test_argparse.py29
1 files changed, 24 insertions, 5 deletions
diff --git a/test/test_argparse.py b/test/test_argparse.py
index 6c8ee06..ad2be1a 100644
--- a/test/test_argparse.py
+++ b/test/test_argparse.py
@@ -1420,12 +1420,9 @@ class TestTypeUserDefined(ParserTestCase):
def __eq__(self, other):
return (type(self), self.value) == (type(other), other.value)
- def get_my_type(value):
- return TestTypeUserDefined.MyType(value)
-
argument_signatures = [
- Sig('-x', type=get_my_type),
- Sig('spam', type=get_my_type),
+ Sig('-x', type=MyType),
+ Sig('spam', type=MyType),
]
failures = []
successes = [
@@ -1434,6 +1431,28 @@ class TestTypeUserDefined(ParserTestCase):
]
+class TestTypeClassicClass(ParserTestCase):
+ """Test a classic class type"""
+
+ class C:
+
+ def __init__(self, value):
+ self.value = value
+
+ def __eq__(self, other):
+ return (type(self), self.value) == (type(other), other.value)
+
+ argument_signatures = [
+ Sig('-x', type=C),
+ Sig('spam', type=C),
+ ]
+ failures = []
+ successes = [
+ ('a -x b', NS(x=C('b'), spam=C('a'))),
+ ('-xf g', NS(x=C('f'), spam=C('g'))),
+ ]
+
+
class TestTypeRegistration(TestCase):
"""Test a user-defined type by registering it"""