MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / generate_validator_testcases

Function generate_validator_testcases

lib/matplotlib/tests/test_rcparams.py:212–443  ·  view source on GitHub ↗
(valid)

Source from the content-addressed store, hash-verified

210
211
212def generate_validator_testcases(valid):
213 validation_tests = (
214 {'validator': validate_bool,
215 'success': (*((_, True) for _ in
216 ('t', 'y', 'yes', 'on', 'true', '1', 1, True)),
217 *((_, False) for _ in
218 ('f', 'n', 'no', 'off', 'false', '0', 0, False))),
219 'fail': ((_, ValueError)
220 for _ in ('aardvark', 2, -1, [], ))
221 },
222 {'validator': validate_stringlist,
223 'success': (('', []),
224 ('a,b', ['a', 'b']),
225 ('aardvark', ['aardvark']),
226 ('aardvark, ', ['aardvark']),
227 ('aardvark, ,', ['aardvark']),
228 (['a', 'b'], ['a', 'b']),
229 (('a', 'b'), ['a', 'b']),
230 (iter(['a', 'b']), ['a', 'b']),
231 (np.array(['a', 'b']), ['a', 'b']),
232 ),
233 'fail': ((set(), ValueError),
234 (1, ValueError),
235 )
236 },
237 {'validator': _listify_validator(validate_int, n=2),
238 'success': ((_, [1, 2])
239 for _ in ('1, 2', [1.5, 2.5], [1, 2],
240 (1, 2), np.array((1, 2)))),
241 'fail': ((_, ValueError)
242 for _ in ('aardvark', ('a', 1),
243 (1, 2, 3)
244 ))
245 },
246 {'validator': _listify_validator(validate_float, n=2),
247 'success': ((_, [1.5, 2.5])
248 for _ in ('1.5, 2.5', [1.5, 2.5], [1.5, 2.5],
249 (1.5, 2.5), np.array((1.5, 2.5)))),
250 'fail': ((_, ValueError)
251 for _ in ('aardvark', ('a', 1), (1, 2, 3), (None, ), None))
252 },
253 {'validator': validate_cycler,
254 'success': (('cycler("color", "rgb")',
255 cycler("color", 'rgb')),
256 ('cycler("color", "Dark2")',
257 cycler("color", mpl.color_sequences["Dark2"])),
258 (cycler('linestyle', ['-', '--']),
259 cycler('linestyle', ['-', '--'])),
260 ("""(cycler("color", ["r", "g", "b"]) +
261 cycler("mew", [2, 3, 5]))""",
262 (cycler("color", 'rgb') +
263 cycler("markeredgewidth", [2, 3, 5]))),
264 ("cycler(c='rgb', lw=[1, 2, 3])",
265 cycler('color', 'rgb') + cycler('linewidth', [1, 2, 3])),
266 ("cycler('c', 'rgb') * cycler('linestyle', ['-', '--'])",
267 (cycler('color', 'rgb') *
268 cycler('linestyle', ['-', '--']))),
269 (cycler('ls', ['-', '--']),

Callers

nothing calls this directly

Calls 2

_listify_validatorFunction · 0.90
cyclerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…