changeset 2510:f6a777f45559

clarify None behaviour for keys, add tests
author Johannes Berg <johannes AT sipsolutions DOT net>
date Sun, 22 Jul 2007 16:10:11 +0200
parents a55a20b092a2
children e85e1ebb3459
files MoinMoin/_tests/test_wikiutil.py MoinMoin/wikiutil.py
diffstat 2 files changed, 23 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_wikiutil.py	Sun Jul 22 16:08:37 2007 +0200
+++ b/MoinMoin/_tests/test_wikiutil.py	Sun Jul 22 16:10:11 2007 +0200
@@ -254,15 +254,26 @@
                   (u'  ""  ,"", ""',          ([u'', u'', u''], {}, [])),
                   # some name=value test
                   (u'd = 4,c=3,b=2,a= 1 ',    ([], abcd_dict, [])),
-                  (u'd=d,e="a,b,c,d"',        ([], {u'd':u'd',
-                                                    u'e':u'a,b,c,d'}, [])),
-                  (u'd = d,e = "a,b,c,d"',    ([], {u'd':u'd',
-                                                    u'e':u'a,b,c,d'}, [])),
-                  (u'd = d, e = "a,b,c,d"',   ([], {u'd':u'd',
-                                                    u'e':u'a,b,c,d'}, [])),
+                  (u'd=d,e="a,b,c,d"',        ([], {u'd': u'd',
+                                                    u'e': u'a,b,c,d'}, [])),
+                  (u'd = d,e = "a,b,c,d"',    ([], {u'd': u'd',
+                                                    u'e': u'a,b,c,d'}, [])),
+                  (u'd = d, e = "a,b,c,d"',   ([], {u'd': u'd',
+                                                    u'e': u'a,b,c,d'}, [])),
+                  (u'd = , e = "a,b,c,d"',    ([], {u'd': None,
+                                                    u'e': u'a,b,c,d'}, [])),
+                  (u'd = "", e = "a,b,c,d"',  ([], {u'd': u'',
+                                                    u'e': u'a,b,c,d'}, [])),
+                  (u'd = "", e = ',           ([], {u'd': u'', u'e': None},
+                                               [])),
+                  (u'd = "", e = ""',         ([], {u'd': u'', u'e': u''},
+                                               [])),
+                  # no, None as key isn't accepted
+                  (u' = "",  e = ""',         ([], {u'': u'', u'e': u''},
+                                               [])),
                   # can quote both name and value:
-                  (u'd = d," e "= "a,b,c,d"', ([], {u'd':u'd',
-                                                    u' e ':u'a,b,c,d'}, [])),
+                  (u'd = d," e "= "a,b,c,d"', ([], {u'd': u'd',
+                                                    u' e ': u'a,b,c,d'}, [])),
                   # trailing args
                   (u'1,2,a=b,3,4',            ([u'1', u'2'], {u'a': u'b'},
                                                [u'3', u'4'])),
@@ -293,7 +304,7 @@
                   (u' a , b , c , d ',        abcd),
                   (u'   a   ',                [u'a']),
                   (u'"  a  "',                [u'  a  ']),
-                  (u'a,b,c,d, "a,b,c,d"',     abcd+[u'a,b,c,d']),
+                  (u'a,b,c,d, "a,b,c,d"',     abcd + [u'a,b,c,d']),
                   (u'quote " :), b',          [u'quote " :)', u'b']),
                   (u'"quote "" :)", b',       [u'quote " :)', u'b']),
                   (u'd=d,e="a,b,c,d"',        [u'd=d', u'e="a', u'b',
@@ -305,4 +316,3 @@
 
 
 coverage_modules = ['MoinMoin.wikiutil']
-
--- a/MoinMoin/wikiutil.py	Sun Jul 22 16:08:37 2007 +0200
+++ b/MoinMoin/wikiutil.py	Sun Jul 22 16:10:11 2007 +0200
@@ -1206,8 +1206,9 @@
     keyword args) can both be quoted, when keyword args are enabled
     then the name of a keyword argument can also be quoted.
 
-    Arguments that are not given are returned as None, while the
-    empty string can be achieved by quoting it.
+    Values that are not given are returned as None, while the
+    empty string as a value can be achieved by quoting it; keys
+    are never returned as None.
 
     If a name or value does not start with a quote, then the quote
     character looses its special meaning for that name or value.