diff MoinMoin/_tests/test_wikiutil.py @ 2456:15502589ece6

ParameterParser: check types, remove unused code, tests
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 21 Jul 2007 23:48:56 +0200
parents fe71235f1f7c
children ea255685d6b0
line wrap: on
line diff
--- a/MoinMoin/_tests/test_wikiutil.py	Sat Jul 21 23:00:25 2007 +0200
+++ b/MoinMoin/_tests/test_wikiutil.py	Sat Jul 21 23:48:56 2007 +0200
@@ -199,9 +199,9 @@
             ("%(width)s%(height)s", 'width="really wide"', 0, {'width': 'really wide', 'height': None}),
             ("%(width)s%(height)s", 'height="not too high"', 0, {'width': None, 'height': 'not too high'}),
             ("%(width)s%(height)s", 'width="really wide", height="not too high"', 0, {'width': 'really wide', 'height': 'not too high'}),
-            # XXX for the next 2 tests: unclear: wanted str, given int, shall that give int?
-            ("%(width)s%(height)s", 'width=100', 0, {'width': 100, 'height': None}),
-            ("%(width)s%(height)s", 'width=100, height=200', 0, {'width': 100, 'height': 200}),
+            # conversion from given type to expected type
+            ("%(width)s%(height)s", 'width=100', 0, {'width': '100', 'height': None}),
+            ("%(width)s%(height)s", 'width=100, height=200', 0, {'width': '100', 'height': '200'}),
 
             # complex test
             ("%i%sf%s%ifs%(a)s|%(b)s", ' 4,"DI\'NG", b=retry, a="DING"', 2, {0: 4, 1: "DI'NG", 'a': 'DING', 'b': 'retry'}),
@@ -222,6 +222,16 @@
         argParser = wikiutil.ParameterParser("%(width)s%(height)s")
         py.test.raises(ValueError, argParser.parse_parameters, args)
 
+    def testWrongTypeFixedPosArgument(self):
+        args = '0.0'
+        argParser = wikiutil.ParameterParser("%b")
+        py.test.raises(ValueError, argParser.parse_parameters, args)
+
+    def testWrongTypeNamedArgument(self):
+        args = 'flag=0.0'
+        argParser = wikiutil.ParameterParser("%(flag)b")
+        py.test.raises(ValueError, argParser.parse_parameters, args)
+
 
 coverage_modules = ['MoinMoin.wikiutil']