Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c4d4f11

Browse files
committed
Increased test coverage of markevery validator
1 parent 5eb2665 commit c4d4f11

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

lib/matplotlib/rcsetup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,8 @@ def validate_markevery(s):
568568
raise ValueError("'markevery' tuple with first element of "
569569
"type float must have all elements of type "
570570
"float")
571+
if not instance(tupType, (float, int)):
572+
raise TypeError("'markevery' tuple is of an invalid type")
571573
if isinstance(s, list):
572574
if not all(isinstance(e, int) for e in s):
573575
raise ValueError("'markevery' list must have all elements "

lib/matplotlib/tests/test_rcparams.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -332,22 +332,28 @@ def generate_validator_testcases(valid):
332332
'success': ((None, None),
333333
(1, 1),
334334
(0.1, 0.1),
335-
((1,1), (1,1)),
336-
((0.1,0.1), (0.1,0.1)),
337-
([1,2,3], [1,2,3]),
338-
(slice(2), slice(None,2,None)),
339-
(slice(1,2,3), slice(1,2,3))
335+
((1, 1), (1, 1)),
336+
((0.1, 0.1), (0.1, 0.1)),
337+
([1, 2, 3], [1, 2, 3]),
338+
(slice(2), slice(None, 2, None)),
339+
(slice(1, 2, 3), slice(1, 2, 3))
340340
),
341-
'fail': (((1,2,3), ValueError),
342-
((0.1,0.2,0.3), ValueError),
343-
((0.1,2,3), ValueError),
344-
((1,0.2,0.3), ValueError),
345-
((1,0.1), ValueError),
346-
((0.1,1), ValueError),
341+
'fail': (((1, 2, 3), ValueError),
342+
([1, 2, 0.3], ValueError),
343+
(['a', 2, 3], ValueError),
344+
([1, 2, 'a'], ValueError),
345+
((0.1, 0.2, 0.3), ValueError),
346+
((0.1, 2, 3), ValueError),
347+
((1, 0.2, 0.3), ValueError),
348+
((1, 0.1), ValueError),
349+
((0.1, 1), ValueError),
347350
(('abc'), ValueError),
348-
(('a'), ValueError),
349-
('abc', ValueError),
350-
('a', ValueError)
351+
((1, 'a'), ValueError),
352+
((0.1, 'b'), ValueError),
353+
(('a', 1), ValueError),
354+
(('a', 0.1), ValueError),
355+
('abc', TypeError),
356+
('a', TypeError)
351357
)
352358
}
353359
)

0 commit comments

Comments
 (0)