comparison MoinMoin/_tests/test_wikiutil.py @ 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 ea255685d6b0
children 68496057ee03
comparison
equal deleted inserted replaced
2509:a55a20b092a2 2510:f6a777f45559
252 (u',"",', ([None, u'', None], {}, [])), 252 (u',"",', ([None, u'', None], {}, [])),
253 (u',"", ""', ([None, u'', u''], {}, [])), 253 (u',"", ""', ([None, u'', u''], {}, [])),
254 (u' "" ,"", ""', ([u'', u'', u''], {}, [])), 254 (u' "" ,"", ""', ([u'', u'', u''], {}, [])),
255 # some name=value test 255 # some name=value test
256 (u'd = 4,c=3,b=2,a= 1 ', ([], abcd_dict, [])), 256 (u'd = 4,c=3,b=2,a= 1 ', ([], abcd_dict, [])),
257 (u'd=d,e="a,b,c,d"', ([], {u'd':u'd', 257 (u'd=d,e="a,b,c,d"', ([], {u'd': u'd',
258 u'e':u'a,b,c,d'}, [])), 258 u'e': u'a,b,c,d'}, [])),
259 (u'd = d,e = "a,b,c,d"', ([], {u'd':u'd', 259 (u'd = d,e = "a,b,c,d"', ([], {u'd': u'd',
260 u'e':u'a,b,c,d'}, [])), 260 u'e': u'a,b,c,d'}, [])),
261 (u'd = d, e = "a,b,c,d"', ([], {u'd':u'd', 261 (u'd = d, e = "a,b,c,d"', ([], {u'd': u'd',
262 u'e':u'a,b,c,d'}, [])), 262 u'e': u'a,b,c,d'}, [])),
263 (u'd = , e = "a,b,c,d"', ([], {u'd': None,
264 u'e': u'a,b,c,d'}, [])),
265 (u'd = "", e = "a,b,c,d"', ([], {u'd': u'',
266 u'e': u'a,b,c,d'}, [])),
267 (u'd = "", e = ', ([], {u'd': u'', u'e': None},
268 [])),
269 (u'd = "", e = ""', ([], {u'd': u'', u'e': u''},
270 [])),
271 # no, None as key isn't accepted
272 (u' = "", e = ""', ([], {u'': u'', u'e': u''},
273 [])),
263 # can quote both name and value: 274 # can quote both name and value:
264 (u'd = d," e "= "a,b,c,d"', ([], {u'd':u'd', 275 (u'd = d," e "= "a,b,c,d"', ([], {u'd': u'd',
265 u' e ':u'a,b,c,d'}, [])), 276 u' e ': u'a,b,c,d'}, [])),
266 # trailing args 277 # trailing args
267 (u'1,2,a=b,3,4', ([u'1', u'2'], {u'a': u'b'}, 278 (u'1,2,a=b,3,4', ([u'1', u'2'], {u'a': u'b'},
268 [u'3', u'4'])), 279 [u'3', u'4'])),
269 ] 280 ]
270 for args, expected in tests: 281 for args, expected in tests:
291 u'b=2', u'a= 1']), 302 u'b=2', u'a= 1']),
292 (u'a,b,c,d', abcd), 303 (u'a,b,c,d', abcd),
293 (u' a , b , c , d ', abcd), 304 (u' a , b , c , d ', abcd),
294 (u' a ', [u'a']), 305 (u' a ', [u'a']),
295 (u'" a "', [u' a ']), 306 (u'" a "', [u' a ']),
296 (u'a,b,c,d, "a,b,c,d"', abcd+[u'a,b,c,d']), 307 (u'a,b,c,d, "a,b,c,d"', abcd + [u'a,b,c,d']),
297 (u'quote " :), b', [u'quote " :)', u'b']), 308 (u'quote " :), b', [u'quote " :)', u'b']),
298 (u'"quote "" :)", b', [u'quote " :)', u'b']), 309 (u'"quote "" :)", b', [u'quote " :)', u'b']),
299 (u'd=d,e="a,b,c,d"', [u'd=d', u'e="a', u'b', 310 (u'd=d,e="a,b,c,d"', [u'd=d', u'e="a', u'b',
300 u'c', u'd"']), 311 u'c', u'd"']),
301 ] 312 ]
303 result = wikiutil.parse_quoted_separated(args, name_value=False) 314 result = wikiutil.parse_quoted_separated(args, name_value=False)
304 assert expected == result 315 assert expected == result
305 316
306 317
307 coverage_modules = ['MoinMoin.wikiutil'] 318 coverage_modules = ['MoinMoin.wikiutil']
308