• Home
  • Raw
  • Download

Lines Matching full:doctest

1 # Module doctest.
9 r"""Module doctest -- a framework for running examples in docstrings.
14 import doctest
15 doctest.testmod()
44 of doctest's default behaviors. See the Library Reference Manual for
66 # 2. Example & DocTest
68 'DocTest',
69 # 3. Doctest Parser
71 # 4. Doctest Finder
73 # 5. Doctest Runner
108 # - DocTest: a collection of examples, parsed from a docstring, plus
112 # - DocTestRunner: runs DocTest cases, and accumulates statistics.
118 # |object| --DocTestFinder-> | DocTest | --DocTestRunner-> |results|
164 # 2. Example & DocTest -- store test cases
165 # 3. DocTest Parser -- extracts examples from strings
166 # 4. DocTest Finder -- extracts test cases from objects
167 # 5. DocTest Runner -- runs test cases
416 ## 2. Example & DocTest
423 ## - A "doctest" is a collection of examples, typically extracted from
424 ## a string (such as an object's docstring). The DocTest class also
429 A single doctest example, consisting of source code and expected
448 - lineno: The line number within the DocTest string containing
450 zero-based, with respect to the beginning of the DocTest.
452 - indent: The example's indentation in the DocTest string.
499 class DocTest: class
501 A collection of doctest examples that should be run in a single
502 namespace. Each `DocTest` defines the following attributes:
509 - name: A name identifying the DocTest (typically, the name of
510 the object whose docstring this DocTest was extracted from).
512 - filename: The name of the file that this DocTest was extracted
515 - lineno: The line number within filename where this DocTest
525 Create a new DocTest containing the given examples. The
526 DocTest's globals are initialized with a copy of `globs`.
529 "DocTest no longer accepts str; use DocTestParser instead"
544 return ('<DocTest %s from %s:%s (%s)>' %
566 if not isinstance(other, DocTest):
577 A class used to parse strings containing doctest examples.
579 # This regular expression is used to find doctest examples in a
639 # Find all doctest examples in the string:
664 Extract all doctest examples from the given string, and
665 collect them into a `DocTest` object.
668 the new `DocTest` object. See the documentation for `DocTest`
671 return DocTest(self.get_examples(string, name), globs,
676 Extract all doctest examples from the given string, and return
734 # starting with "doctest:". Warning: this may give false
736 # "#doctest:". Eliminating these false positives would require
738 # line containing "#doctest:" that is *followed* by a quote mark.
739 _OPTION_DIRECTIVE_RE = re.compile(r'#\s*doctest:\s*([^\n\'"]*)$',
757 raise ValueError('line %r of the doctest for %s '
763 raise ValueError('line %r of the doctest for %s has an option '
807 ## 4. DocTest Finder
822 Create a new doctest finder.
825 function that should be used to create new DocTest objects (or
826 objects that implement the same interface as DocTest). The
828 of the DocTest constructor.
867 The globals for each DocTest is formed by combining `globs`
870 for each DocTest. If `globs` is not specified, then it
928 # verbose-mode output. This was a feature of doctest in Pythons
1019 Return a DocTest for the given object, if it defines a docstring;
1044 # Return a DocTest for this object.
1103 ## 5. DocTest Runner
1108 A class used to run DocTest test cases, and accumulate statistics.
1109 The `run` method is used to process a single DocTest case. It
1172 outputs of doctest examples.
1195 # Create a fake output target for capturing doctest output.
1254 # DocTest Running
1307 filename = '<doctest %s[%d]>' % (test.name, examplenum)
1382 Record the fact that the given DocTest (`test`) generated `f`
1390 __LINECACHE_FILENAME_RE = re.compile(r'<doctest '
1521 # Backward compatibility cruft to maintain doctest.master.
1538 A class used to check the whether the actual output from a doctest
1579 # This flag causes doctest to ignore any differences in the
1670 """A DocTest example has failed in debugging mode.
1674 - test: the DocTest object being run
1689 """A DocTest example has encountered an unexpected exception
1693 - test: the DocTest object being run
1778 UnexpectedException: <DocTest foo from foo.py:0 (2 examples)>
1837 See help(doctest) for an overview.
1878 class doctest.Tester, then merges the results into (or creates)
1879 global Tester instance doctest.master. Methods of doctest.master
1882 displaying a summary. Invoke doctest.master.summarize(verbose)
1996 class doctest.Tester, then merges the results into (or creates)
1997 global Tester instance doctest.master. Methods of doctest.master
2000 displaying a summary. Invoke doctest.master.summarize(verbose)
2081 "use class doctest.DocTestRunner instead",
2148 >>> import doctest
2149 >>> old = doctest._unittest_reportflags
2150 >>> doctest.set_unittest_reportflags(REPORT_NDIFF |
2154 >>> doctest._unittest_reportflags == (REPORT_NDIFF |
2160 >>> doctest.set_unittest_reportflags(ELLIPSIS)
2165 >>> doctest.set_unittest_reportflags(old) == (REPORT_NDIFF |
2235 return ('Failed doctest test for %s\n'
2339 return "Doctest: " + self._dt_test.name
2361 Convert doctest tests for a module to a unittest test suite.
2364 contains doctest tests to a unittest test case. If any of the
2378 tests in each file. The setUp function will be passed a DocTest
2384 tests in each file. The tearDown function will be passed a DocTest
2392 A set of doctest option flags expressed as an integer.
2410 # number of doctest examples in tests is zero (i.e. if no doctest
2441 return ('Failed doctest test for %s\n File "%s", line 0\n\n%s'
2475 """A unittest suite for one or more doctest files.
2477 The path to each doctest file is given as a string; the
2507 tests in each file. The setUp function will be passed a DocTest
2513 tests in each file. The tearDown function will be passed a DocTest
2521 A set of doctest option flags expressed as an integer.
2630 """Extract the test sources from a doctest docstring as a script.
2646 """Debug a single doctest docstring, in argument `src`'"""
2683 """Debug a single doctest docstring.
2776 >>> print range(1000) #doctest: +ELLIPSIS
2783 >>> print range(30) #doctest: +NORMALIZE_WHITESPACE