MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / Xdoctester

Class Xdoctester

tools/sampcd_processor.py:347–655  ·  view source on GitHub ↗

A Xdoctest doctester.

Source from the content-addressed store, hash-verified

345
346
347class Xdoctester(DocTester):
348 """A Xdoctest doctester."""
349
350 directives: dict[str, tuple[type[Directive], ...]] = {
351 'timeout': (TimeoutDirective, TEST_TIMEOUT),
352 'solo': (SingleProcessDirective,),
353 }
354
355 bad_statements: dict[str, tuple[type[BadStatement], ...]] = {
356 'fluid': (Fluid,),
357 'skip': (SkipNoReason,),
358 'require': (DeprecatedRequired,),
359 }
360
361 def __init__(
362 self,
363 debug=False,
364 style='freeform',
365 target='codeblock',
366 mode='native',
367 verbose=2,
368 patch_global_state=True,
369 patch_tensor_place=True,
370 patch_float_precision=5,
371 use_multiprocessing=True,
372 **config,
373 ):
374 self.debug = debug
375
376 self.style = style
377 self.target = target
378 self.mode = mode
379 self.verbose = verbose
380 self.config = XDOCTEST_CONFIG | (config or {})
381 self._test_capacity = set()
382
383 self._patch_global_state = patch_global_state
384 self._patch_tensor_place = patch_tensor_place
385 self._patch_float_precision = patch_float_precision
386 self._use_multiprocessing = use_multiprocessing
387
388 # patch xdoctest before `xdoctest.core.parse_docstr_examples`
389 self._patch_xdoctest()
390
391 self.docstring_parser = functools.partial(
392 xdoctest.core.parse_docstr_examples, style=self.style
393 )
394
395 self.directive_pattern = re.compile(
396 r"""
397 (?<=(\#\s)) # positive lookbehind, directive begins
398 (doctest) # directive prefix, which should be replaced
399 (?=(:\s*.*\n)) # positive lookahead, directive content
400 """,
401 re.VERBOSE,
402 )
403
404 self.directive_prefix = 'xdoctest'

Callers 15

test_initMethod · 0.90
test_prepareMethod · 0.90
test_global_execMethod · 0.90
test_run_cpuMethod · 0.90
test_run_gpuMethod · 0.90
test_style_googleMethod · 0.90
test_style_freeformMethod · 0.90
test_no_codeMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_initMethod · 0.72
test_prepareMethod · 0.72
test_global_execMethod · 0.72
test_run_cpuMethod · 0.72
test_run_gpuMethod · 0.72
test_style_googleMethod · 0.72
test_style_freeformMethod · 0.72
test_no_codeMethod · 0.72