@@ -332,71 +332,60 @@ def generate_validator_testcases(valid):
332332 ),
333333 'fail' : (('aardvark' , ValueError ),
334334 )
335- },
336- {'validator' : validate_markevery ,
337- 'success' : ((None , None ),
338- (1 , 1 ),
339- (0.1 , 0.1 ),
340- ((1 , 1 ), (1 , 1 )),
341- ((0.1 , 0.1 ), (0.1 , 0.1 )),
342- ([1 , 2 , 3 ], [1 , 2 , 3 ]),
343- (slice (2 ), slice (None , 2 , None )),
344- (slice (1 , 2 , 3 ), slice (1 , 2 , 3 ))
345- ),
346- 'fail' : (((1 , 2 , 3 ), TypeError ),
347- ([1 , 2 , 0.3 ], TypeError ),
348- (['a' , 2 , 3 ], TypeError ),
349- ([1 , 2 , 'a' ], TypeError ),
350- ((0.1 , 0.2 , 0.3 ), TypeError ),
351- ((0.1 , 2 , 3 ), TypeError ),
352- ((1 , 0.2 , 0.3 ), TypeError ),
353- ((1 , 0.1 ), TypeError ),
354- ((0.1 , 1 ), TypeError ),
355- (('abc' ), TypeError ),
356- ((1 , 'a' ), TypeError ),
357- ((0.1 , 'b' ), TypeError ),
358- (('a' , 1 ), TypeError ),
359- (('a' , 0.1 ), TypeError ),
360- ('abc' , TypeError ),
361- ('a' , TypeError ),
362- (object (), TypeError )
363- )
364- }
335+ },
336+ {'validator' : validate_markevery ,
337+ 'success' : ((None , None ),
338+ (1 , 1 ),
339+ (0.1 , 0.1 ),
340+ ((1 , 1 ), (1 , 1 )),
341+ ((0.1 , 0.1 ), (0.1 , 0.1 )),
342+ ([1 , 2 , 3 ], [1 , 2 , 3 ]),
343+ (slice (2 ), slice (None , 2 , None )),
344+ (slice (1 , 2 , 3 ), slice (1 , 2 , 3 ))
345+ ),
346+ 'fail' : (((1 , 2 , 3 ), TypeError ),
347+ ([1 , 2 , 0.3 ], TypeError ),
348+ (['a' , 2 , 3 ], TypeError ),
349+ ([1 , 2 , 'a' ], TypeError ),
350+ ((0.1 , 0.2 , 0.3 ), TypeError ),
351+ ((0.1 , 2 , 3 ), TypeError ),
352+ ((1 , 0.2 , 0.3 ), TypeError ),
353+ ((1 , 0.1 ), TypeError ),
354+ ((0.1 , 1 ), TypeError ),
355+ (('abc' ), TypeError ),
356+ ((1 , 'a' ), TypeError ),
357+ ((0.1 , 'b' ), TypeError ),
358+ (('a' , 1 ), TypeError ),
359+ (('a' , 0.1 ), TypeError ),
360+ ('abc' , TypeError ),
361+ ('a' , TypeError ),
362+ (object (), TypeError )
363+ )
364+ },
365+ {'validator' : _validate_linestyle ,
366+ 'success' : (('-' , '-' ), ('solid' , 'solid' ),
367+ ('--' , '--' ), ('dashed' , 'dashed' ),
368+ ('-.' , '-.' ), ('dashdot' , 'dashdot' ),
369+ (':' , ':' ), ('dotted' , 'dotted' ),
370+ ('' , '' ), (' ' , ' ' ),
371+ ('None' , 'none' ), ('none' , 'none' ),
372+ ('DoTtEd' , 'dotted' ), # case-insensitive
373+ (['1.23' , '4.56' ], (None , [1.23 , 4.56 ])),
374+ ([1.23 , 456 ], (None , [1.23 , 456.0 ])),
375+ ([1 , 2 , 3 , 4 ], (None , [1.0 , 2.0 , 3.0 , 4.0 ])),
376+ ),
377+ 'fail' : (('aardvark' , ValueError ), # not a valid string
378+ (b'dotted' , ValueError ),
379+ ('dotted' .encode ('utf-16' ), ValueError ),
380+ ((None , [1 , 2 ]), ValueError ), # (offset, dashes) != OK
381+ ((0 , [1 , 2 ]), ValueError ), # idem
382+ ((- 1 , [1 , 2 ]), ValueError ), # idem
383+ ([1 , 2 , 3 ], ValueError ), # sequence with odd length
384+ (1.23 , ValueError ), # not a sequence
385+ )
386+ },
365387 )
366388
367- # The behavior of _validate_linestyle depends on the version of Python.
368- # ASCII-compliant bytes arguments should pass on Python 2 because of the
369- # automatic conversion between bytes and strings. Python 3 does not
370- # perform such a conversion, so the same cases should raise an exception.
371- #
372- # Common cases:
373- ls_test = {'validator' : _validate_linestyle ,
374- 'success' : (('-' , '-' ), ('solid' , 'solid' ),
375- ('--' , '--' ), ('dashed' , 'dashed' ),
376- ('-.' , '-.' ), ('dashdot' , 'dashdot' ),
377- (':' , ':' ), ('dotted' , 'dotted' ),
378- ('' , '' ), (' ' , ' ' ),
379- ('None' , 'none' ), ('none' , 'none' ),
380- ('DoTtEd' , 'dotted' ), # case-insensitive
381- (['1.23' , '4.56' ], (None , [1.23 , 4.56 ])),
382- ([1.23 , 456 ], (None , [1.23 , 456.0 ])),
383- ([1 , 2 , 3 , 4 ], (None , [1.0 , 2.0 , 3.0 , 4.0 ])),
384- ),
385- 'fail' : (('aardvark' , ValueError ), # not a valid string
386- ('dotted' .encode ('utf-16' ), ValueError ), # even on PY2
387- ((None , [1 , 2 ]), ValueError ), # (offset, dashes) != OK
388- ((0 , [1 , 2 ]), ValueError ), # idem
389- ((- 1 , [1 , 2 ]), ValueError ), # idem
390- ([1 , 2 , 3 ], ValueError ), # sequence with odd length
391- (1.23 , ValueError ), # not a sequence
392- )
393- }
394- # Add some cases of bytes arguments that Python 2 can convert silently:
395- ls_bytes_args = (b'dotted' , 'dotted' .encode ('ascii' ))
396- ls_test ['fail' ] += tuple ((arg , ValueError ) for arg in ls_bytes_args )
397- # Update the validation test sequence.
398- validation_tests += (ls_test ,)
399-
400389 for validator_dict in validation_tests :
401390 validator = validator_dict ['validator' ]
402391 if valid :
0 commit comments