{
    "mode": "pydoc",
    "parameter": "doctest",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/doctest/json",
    "generated": "2026-06-02T13:21:08Z",
    "sections": {
        "NAME": {
            "content": "doctest - Module doctest -- a framework for running examples in docstrings.\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/doctest.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "In simplest use, end each module M to be tested with:\n\ndef test():\nimport doctest\ndoctest.testmod()\n\nif name == \"main\":\ntest()\n\nThen running the module as a script will cause the examples in the\ndocstrings to get executed and verified:\n\npython M.py\n\nThis won't display anything unless an example fails, in which case the\nfailing example(s) and the cause(s) of the failure(s) are printed to stdout\n(why not stderr? because stderr is a lame hack <0.2 wink>), and the final\nline of output is \"Test failed.\".\n\nRun it with the -v switch instead:\n\npython M.py -v\n\nand a detailed report of all examples tried is printed to stdout, along\nwith assorted summaries at the end.\n\nYou can force verbose mode by passing \"verbose=True\" to testmod, or prohibit\nit by passing \"verbose=False\".  In either of those cases, sys.argv is not\nexamined by testmod.\n\nThere are a variety of other ways to run doctests, including integration\nwith the unittest framework, and support for running non-Python text\nfiles containing doctests.  There are also many ways to override parts\nof doctest's default behaviors.  See the Library Reference Manual for\ndetails.\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.Exception(builtins.BaseException)\nDocTestFailure\nUnexpectedException\nbuiltins.object\nDocTest\nDocTestFinder\nDocTestParser\nDocTestRunner\nDebugRunner\nExample\nOutputChecker\n",
            "subsections": [
                {
                    "name": "class DebugRunner",
                    "content": "|  DebugRunner(checker=None, verbose=None, optionflags=0)\n|\n|  Run doc tests but raise an exception as soon as there is a failure.\n|\n|  If an unexpected exception occurs, an UnexpectedException is raised.\n|  It contains the test, the example, and the original exception:\n|\n|    >>> runner = DebugRunner(verbose=False)\n|    >>> test = DocTestParser().getdoctest('>>> raise KeyError\\n42',\n|    ...                                    {}, 'foo', 'foo.py', 0)\n|    >>> try:\n|    ...     runner.run(test)\n|    ... except UnexpectedException as f:\n|    ...     failure = f\n|\n|    >>> failure.test is test\n|    True\n|\n|    >>> failure.example.want\n|    '42\\n'\n|\n|    >>> excinfo = failure.excinfo\n|    >>> raise excinfo[1] # Already has the traceback\n|    Traceback (most recent call last):\n|    ...\n|    KeyError\n|\n|  We wrap the original exception to give the calling application\n|  access to the test and example information.\n|\n|  If the output doesn't match, then a DocTestFailure is raised:\n|\n|    >>> test = DocTestParser().getdoctest('''\n|    ...      >>> x = 1\n|    ...      >>> x\n|    ...      2\n|    ...      ''', {}, 'foo', 'foo.py', 0)\n|\n|    >>> try:\n|    ...    runner.run(test)\n|    ... except DocTestFailure as f:\n|    ...    failure = f\n|\n|  DocTestFailure objects provide access to the test:\n|\n|    >>> failure.test is test\n|    True\n|\n|  As well as to the example:\n|\n|    >>> failure.example.want\n|    '2\\n'\n|\n|  and the actual output:\n|\n|    >>> failure.got\n|    '1\\n'\n|\n|  If a failure or error occurs, the globals are left intact:\n|\n|    >>> del test.globs['builtins']\n|    >>> test.globs\n|    {'x': 1}\n|\n|    >>> test = DocTestParser().getdoctest('''\n|    ...      >>> x = 2\n|    ...      >>> raise KeyError\n|    ...      ''', {}, 'foo', 'foo.py', 0)\n|\n|    >>> runner.run(test)\n|    Traceback (most recent call last):\n|    ...\n|    doctest.UnexpectedException: <DocTest foo from foo.py:0 (2 examples)>\n|\n|    >>> del test.globs['builtins']\n|    >>> test.globs\n|    {'x': 2}\n|\n|  But the globals are cleared if there is no error:\n|\n|    >>> test = DocTestParser().getdoctest('''\n|    ...      >>> x = 2\n|    ...      ''', {}, 'foo', 'foo.py', 0)\n|\n|    >>> runner.run(test)\n|    TestResults(failed=0, attempted=1)\n|\n|    >>> test.globs\n|    {}\n|\n|  Method resolution order:\n|      DebugRunner\n|      DocTestRunner\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  reportfailure(self, out, test, example, got)\n|      Report that the given example failed.\n|\n|  reportunexpectedexception(self, out, test, example, excinfo)\n|      Report that the given example raised an unexpected exception.\n|\n|  run(self, test, compileflags=None, out=None, clearglobs=True)\n|      Run the examples in `test`, and display the results using the\n|      writer function `out`.\n|\n|      The examples are run in the namespace `test.globs`.  If\n|      `clearglobs` is true (the default), then this namespace will\n|      be cleared after the test runs, to help with garbage\n|      collection.  If you would like to examine the namespace after\n|      the test completes, then use `clearglobs=False`.\n|\n|      `compileflags` gives the set of flags that should be used by\n|      the Python compiler when running the examples.  If not\n|      specified, then it will default to the set of future-import\n|      flags that apply to `globs`.\n|\n|      The output of each example is checked using\n|      `DocTestRunner.checkoutput`, and the results are formatted by\n|      the `DocTestRunner.report*` methods.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from DocTestRunner:\n|\n|  init(self, checker=None, verbose=None, optionflags=0)\n|      Create a new test runner.\n|\n|      Optional keyword arg `checker` is the `OutputChecker` that\n|      should be used to compare the expected outputs and actual\n|      outputs of doctest examples.\n|\n|      Optional keyword arg 'verbose' prints lots of stuff if true,\n|      only failures if false; by default, it's true iff '-v' is in\n|      sys.argv.\n|\n|      Optional argument `optionflags` can be used to control how the\n|      test runner compares expected output to actual output, and how\n|      it displays failures.  See the documentation for `testmod` for\n|      more information.\n|\n|  merge(self, other)\n|      #/////////////////////////////////////////////////////////////////\n|      # Backward compatibility cruft to maintain doctest.master.\n|      #/////////////////////////////////////////////////////////////////\n|\n|  reportstart(self, out, test, example)\n|      Report that the test runner is about to process the given\n|      example.  (Only displays a message if verbose=True)\n|\n|  reportsuccess(self, out, test, example, got)\n|      Report that the given example ran successfully.  (Only\n|      displays a message if verbose=True)\n|\n|  summarize(self, verbose=None)\n|      Print a summary of all the test cases that have been run by\n|      this DocTestRunner, and return a tuple `(f, t)`, where `f` is\n|      the total number of failed examples, and `t` is the total\n|      number of tried examples.\n|\n|      The optional `verbose` argument controls how detailed the\n|      summary is.  If the verbosity is not specified, then the\n|      DocTestRunner's verbosity is used.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from DocTestRunner:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes inherited from DocTestRunner:\n|\n|  DIVIDER = '*...\n"
                },
                {
                    "name": "class DocTest",
                    "content": "|  DocTest(examples, globs, name, filename, lineno, docstring)\n|\n|  A collection of doctest examples that should be run in a single\n|  namespace.  Each `DocTest` defines the following attributes:\n|\n|    - examples: the list of examples.\n|\n|    - globs: The namespace (aka globals) that the examples should\n|      be run in.\n|\n|    - name: A name identifying the DocTest (typically, the name of\n|      the object whose docstring this DocTest was extracted from).\n|\n|    - filename: The name of the file that this DocTest was extracted\n|      from, or `None` if the filename is unknown.\n|\n|    - lineno: The line number within filename where this DocTest\n|      begins, or `None` if the line number is unavailable.  This\n|      line number is zero-based, with respect to the beginning of\n|      the file.\n|\n|    - docstring: The string that the examples were extracted from,\n|      or `None` if the string is unavailable.\n|\n|  Methods defined here:\n|\n|  eq(self, other)\n|      Return self==value.\n|\n|  hash(self)\n|      Return hash(self).\n|\n|  init(self, examples, globs, name, filename, lineno, docstring)\n|      Create a new DocTest containing the given examples.  The\n|      DocTest's globals are initialized with a copy of `globs`.\n|\n|  lt(self, other)\n|      Return self<value.\n|\n|  repr(self)\n|      Return repr(self).\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class DocTestFailure",
                    "content": "|  DocTestFailure(test, example, got)\n|\n|  A DocTest example has failed in debugging mode.\n|\n|  The exception instance has variables:\n|\n|  - test: the DocTest object being run\n|\n|  - example: the Example object that failed\n|\n|  - got: the actual output\n|\n|  Method resolution order:\n|      DocTestFailure\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  init(self, test, example, got)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  str(self)\n|      Return str(self).\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                },
                {
                    "name": "class DocTestFinder",
                    "content": "|  DocTestFinder(verbose=False, parser=<doctest.DocTestParser object at 0x7eff6a7898d0>, recurse=True, excludeempty=True)\n|\n|  A class used to extract the DocTests that are relevant to a given\n|  object, from its docstring and the docstrings of its contained\n|  objects.  Doctests can currently be extracted from the following\n|  object types: modules, functions, classes, methods, staticmethods,\n|  classmethods, and properties.\n|\n|  Methods defined here:\n|\n|  init(self, verbose=False, parser=<doctest.DocTestParser object at 0x7eff6a7898d0>, recurse=True, excludeempty=True)\n|      Create a new doctest finder.\n|\n|      The optional argument `parser` specifies a class or\n|      function that should be used to create new DocTest objects (or\n|      objects that implement the same interface as DocTest).  The\n|      signature for this factory function should match the signature\n|      of the DocTest constructor.\n|\n|      If the optional argument `recurse` is false, then `find` will\n|      only examine the given object, and not any contained objects.\n|\n|      If the optional argument `excludeempty` is false, then `find`\n|      will include tests for objects with empty docstrings.\n|\n|  find(self, obj, name=None, module=None, globs=None, extraglobs=None)\n|      Return a list of the DocTests that are defined by the given\n|      object's docstring, or by any of its contained objects'\n|      docstrings.\n|\n|      The optional parameter `module` is the module that contains\n|      the given object.  If the module is not specified or is None, then\n|      the test finder will attempt to automatically determine the\n|      correct module.  The object's module is used:\n|\n|          - As a default namespace, if `globs` is not specified.\n|          - To prevent the DocTestFinder from extracting DocTests\n|            from objects that are imported from other modules.\n|          - To find the name of the file containing the object.\n|          - To help find the line number of the object within its\n|            file.\n|\n|      Contained objects whose module does not match `module` are ignored.\n|\n|      If `module` is False, no attempt to find the module will be made.\n|      This is obscure, of use mostly in tests:  if `module` is False, or\n|      is None but cannot be found automatically, then all objects are\n|      considered to belong to the (non-existent) module, so all contained\n|      objects will (recursively) be searched for doctests.\n|\n|      The globals for each DocTest is formed by combining `globs`\n|      and `extraglobs` (bindings in `extraglobs` override bindings\n|      in `globs`).  A new copy of the globals dictionary is created\n|      for each DocTest.  If `globs` is not specified, then it\n|      defaults to the module's `dict`, if specified, or {}\n|      otherwise.  If `extraglobs` is not specified, then it defaults\n|      to {}.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class DocTestParser",
                    "content": "|  A class used to parse strings containing doctest examples.\n|\n|  Methods defined here:\n|\n|  getdoctest(self, string, globs, name, filename, lineno)\n|      Extract all doctest examples from the given string, and\n|      collect them into a `DocTest` object.\n|\n|      `globs`, `name`, `filename`, and `lineno` are attributes for\n|      the new `DocTest` object.  See the documentation for `DocTest`\n|      for more information.\n|\n|  getexamples(self, string, name='<string>')\n|      Extract all doctest examples from the given string, and return\n|      them as a list of `Example` objects.  Line numbers are\n|      0-based, because it's most common in doctests that nothing\n|      interesting appears on the same line as opening triple-quote,\n|      and so the first interesting line is called \"line 1\" then.\n|\n|      The optional argument `name` is a name identifying this\n|      string, and is only used for error messages.\n|\n|  parse(self, string, name='<string>')\n|      Divide the given string into examples and intervening text,\n|      and return them as a list of alternating Examples and strings.\n|      Line numbers for the Examples are 0-based.  The optional\n|      argument `name` is a name identifying this string, and is only\n|      used for error messages.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class DocTestRunner",
                    "content": "|  DocTestRunner(checker=None, verbose=None, optionflags=0)\n|\n|  A class used to run DocTest test cases, and accumulate statistics.\n|  The `run` method is used to process a single DocTest case.  It\n|  returns a tuple `(f, t)`, where `t` is the number of test cases\n|  tried, and `f` is the number of test cases that failed.\n|\n|      >>> tests = DocTestFinder().find(TestClass)\n|      >>> runner = DocTestRunner(verbose=False)\n|      >>> tests.sort(key = lambda test: test.name)\n|      >>> for test in tests:\n|      ...     print(test.name, '->', runner.run(test))\n|      TestClass -> TestResults(failed=0, attempted=2)\n|      TestClass.init -> TestResults(failed=0, attempted=2)\n|      TestClass.get -> TestResults(failed=0, attempted=2)\n|      TestClass.square -> TestResults(failed=0, attempted=1)\n|\n|  The `summarize` method prints a summary of all the test cases that\n|  have been run by the runner, and returns an aggregated `(f, t)`\n|  tuple:\n|\n|      >>> runner.summarize(verbose=1)\n|      4 items passed all tests:\n|         2 tests in TestClass\n|         2 tests in TestClass.init\n|         2 tests in TestClass.get\n|         1 tests in TestClass.square\n|      7 tests in 4 items.\n|      7 passed and 0 failed.\n|      Test passed.\n|      TestResults(failed=0, attempted=7)\n|\n|  The aggregated number of tried examples and failed examples is\n|  also available via the `tries` and `failures` attributes:\n|\n|      >>> runner.tries\n|      7\n|      >>> runner.failures\n|      0\n|\n|  The comparison between expected outputs and actual outputs is done\n|  by an `OutputChecker`.  This comparison may be customized with a\n|  number of option flags; see the documentation for `testmod` for\n|  more information.  If the option flags are insufficient, then the\n|  comparison may also be customized by passing a subclass of\n|  `OutputChecker` to the constructor.\n|\n|  The test runner's display output can be controlled in two ways.\n|  First, an output function (`out) can be passed to\n|  `TestRunner.run`; this function will be called with strings that\n|  should be displayed.  It defaults to `sys.stdout.write`.  If\n|  capturing the output is not sufficient, then the display output\n|  can be also customized by subclassing DocTestRunner, and\n|  overriding the methods `reportstart`, `reportsuccess`,\n|  `reportunexpectedexception`, and `reportfailure`.\n|\n|  Methods defined here:\n|\n|  init(self, checker=None, verbose=None, optionflags=0)\n|      Create a new test runner.\n|\n|      Optional keyword arg `checker` is the `OutputChecker` that\n|      should be used to compare the expected outputs and actual\n|      outputs of doctest examples.\n|\n|      Optional keyword arg 'verbose' prints lots of stuff if true,\n|      only failures if false; by default, it's true iff '-v' is in\n|      sys.argv.\n|\n|      Optional argument `optionflags` can be used to control how the\n|      test runner compares expected output to actual output, and how\n|      it displays failures.  See the documentation for `testmod` for\n|      more information.\n|\n|  merge(self, other)\n|      #/////////////////////////////////////////////////////////////////\n|      # Backward compatibility cruft to maintain doctest.master.\n|      #/////////////////////////////////////////////////////////////////\n|\n|  reportfailure(self, out, test, example, got)\n|      Report that the given example failed.\n|\n|  reportstart(self, out, test, example)\n|      Report that the test runner is about to process the given\n|      example.  (Only displays a message if verbose=True)\n|\n|  reportsuccess(self, out, test, example, got)\n|      Report that the given example ran successfully.  (Only\n|      displays a message if verbose=True)\n|\n|  reportunexpectedexception(self, out, test, example, excinfo)\n|      Report that the given example raised an unexpected exception.\n|\n|  run(self, test, compileflags=None, out=None, clearglobs=True)\n|      Run the examples in `test`, and display the results using the\n|      writer function `out`.\n|\n|      The examples are run in the namespace `test.globs`.  If\n|      `clearglobs` is true (the default), then this namespace will\n|      be cleared after the test runs, to help with garbage\n|      collection.  If you would like to examine the namespace after\n|      the test completes, then use `clearglobs=False`.\n|\n|      `compileflags` gives the set of flags that should be used by\n|      the Python compiler when running the examples.  If not\n|      specified, then it will default to the set of future-import\n|      flags that apply to `globs`.\n|\n|      The output of each example is checked using\n|      `DocTestRunner.checkoutput`, and the results are formatted by\n|      the `DocTestRunner.report*` methods.\n|\n|  summarize(self, verbose=None)\n|      Print a summary of all the test cases that have been run by\n|      this DocTestRunner, and return a tuple `(f, t)`, where `f` is\n|      the total number of failed examples, and `t` is the total\n|      number of tried examples.\n|\n|      The optional `verbose` argument controls how detailed the\n|      summary is.  If the verbosity is not specified, then the\n|      DocTestRunner's verbosity is used.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  DIVIDER = '*...\n"
                },
                {
                    "name": "class Example",
                    "content": "|  Example(source, want, excmsg=None, lineno=0, indent=0, options=None)\n|\n|  A single doctest example, consisting of source code and expected\n|  output.  `Example` defines the following attributes:\n|\n|    - source: A single Python statement, always ending with a newline.\n|      The constructor adds a newline if needed.\n|\n|    - want: The expected output from running the source code (either\n|      from stdout, or a traceback in case of exception).  `want` ends\n|      with a newline unless it's empty, in which case it's an empty\n|      string.  The constructor adds a newline if needed.\n|\n|    - excmsg: The exception message generated by the example, if\n|      the example is expected to generate an exception; or `None` if\n|      it is not expected to generate an exception.  This exception\n|      message is compared against the return value of\n|      `traceback.formatexceptiononly()`.  `excmsg` ends with a\n|      newline unless it's `None`.  The constructor adds a newline\n|      if needed.\n|\n|    - lineno: The line number within the DocTest string containing\n|      this Example where the Example begins.  This line number is\n|      zero-based, with respect to the beginning of the DocTest.\n|\n|    - indent: The example's indentation in the DocTest string.\n|      I.e., the number of space characters that precede the\n|      example's first prompt.\n|\n|    - options: A dictionary mapping from option flags to True or\n|      False, which is used to override default options for this\n|      example.  Any option flags not contained in this dictionary\n|      are left at their default value (as specified by the\n|      DocTestRunner's optionflags).  By default, no options are set.\n|\n|  Methods defined here:\n|\n|  eq(self, other)\n|      Return self==value.\n|\n|  hash(self)\n|      Return hash(self).\n|\n|  init(self, source, want, excmsg=None, lineno=0, indent=0, options=None)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class OutputChecker",
                    "content": "|  A class used to check the whether the actual output from a doctest\n|  example matches the expected output.  `OutputChecker` defines two\n|  methods: `checkoutput`, which compares a given pair of outputs,\n|  and returns true if they match; and `outputdifference`, which\n|  returns a string describing the differences between two outputs.\n|\n|  Methods defined here:\n|\n|  checkoutput(self, want, got, optionflags)\n|      Return True iff the actual output from an example (`got`)\n|      matches the expected output (`want`).  These strings are\n|      always considered to match if they are identical; but\n|      depending on what option flags the test runner is using,\n|      several non-exact match types are also possible.  See the\n|      documentation for `TestRunner` for more information about\n|      option flags.\n|\n|  outputdifference(self, example, got, optionflags)\n|      Return a string describing the differences between the\n|      expected output for a given example (`example`) and the actual\n|      output (`got`).  `optionflags` is the set of option flags used\n|      to compare `want` and `got`.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class UnexpectedException",
                    "content": "|  UnexpectedException(test, example, excinfo)\n|\n|  A DocTest example has encountered an unexpected exception\n|\n|  The exception instance has variables:\n|\n|  - test: the DocTest object being run\n|\n|  - example: the Example object that failed\n|\n|  - excinfo: the exception info\n|\n|  Method resolution order:\n|      UnexpectedException\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  init(self, test, example, excinfo)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  str(self)\n|      Return str(self).\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                }
            ]
        },
        "FUNCTIONS": {
            "content": "DocFileSuite(*paths, kw)\nA unittest suite for one or more doctest files.\n\nThe path to each doctest file is given as a string; the\ninterpretation of that string depends on the keyword argument\n\"modulerelative\".\n\nA number of options may be provided as keyword arguments:\n\nmodulerelative\nIf \"modulerelative\" is True, then the given file paths are\ninterpreted as os-independent module-relative paths.  By\ndefault, these paths are relative to the calling module's\ndirectory; but if the \"package\" argument is specified, then\nthey are relative to that package.  To ensure os-independence,\n\"filename\" should use \"/\" characters to separate path\nsegments, and may not be an absolute path (i.e., it may not\nbegin with \"/\").\n\nIf \"modulerelative\" is False, then the given file paths are\ninterpreted as os-specific paths.  These paths may be absolute\nor relative (to the current working directory).\n\npackage\nA Python package or the name of a Python package whose directory\nshould be used as the base directory for module relative paths.\nIf \"package\" is not specified, then the calling module's\ndirectory is used as the base directory for module relative\nfilenames.  It is an error to specify \"package\" if\n\"modulerelative\" is False.\n\nsetUp\nA set-up function.  This is called before running the\ntests in each file. The setUp function will be passed a DocTest\nobject.  The setUp function can access the test globals as the\nglobs attribute of the test passed.\n\ntearDown\nA tear-down function.  This is called after running the\ntests in each file.  The tearDown function will be passed a DocTest\nobject.  The tearDown function can access the test globals as the\nglobs attribute of the test passed.\n\nglobs\nA dictionary containing initial global variables for the tests.\n\noptionflags\nA set of doctest option flags expressed as an integer.\n\nparser\nA DocTestParser (or subclass) that should be used to extract\ntests from the files.\n\nencoding\nAn encoding that will be used to convert the files to unicode.\n\nDocTestSuite(module=None, globs=None, extraglobs=None, testfinder=None, options)\nConvert doctest tests for a module to a unittest test suite.\n\nThis converts each documentation string in a module that\ncontains doctest tests to a unittest test case.  If any of the\ntests in a doc string fail, then the test case fails.  An exception\nis raised showing the name of the file containing the test and a\n(sometimes approximate) line number.\n\nThe `module` argument provides the module to be tested.  The argument\ncan be either a module or a module name.\n\nIf no argument is given, the calling module is used.\n\nA number of options may be provided as keyword arguments:\n\nsetUp\nA set-up function.  This is called before running the\ntests in each file. The setUp function will be passed a DocTest\nobject.  The setUp function can access the test globals as the\nglobs attribute of the test passed.\n\ntearDown\nA tear-down function.  This is called after running the\ntests in each file.  The tearDown function will be passed a DocTest\nobject.  The tearDown function can access the test globals as the\nglobs attribute of the test passed.\n\nglobs\nA dictionary containing initial global variables for the tests.\n\noptionflags\nA set of doctest option flags expressed as an integer.\n",
            "subsections": [
                {
                    "name": "debug",
                    "content": "Debug a single doctest docstring.\n\nProvide the module (or dotted name of the module) containing the\ntest to be debugged and the name (within the module) of the object\nwith the docstring with tests to be debugged.\n"
                },
                {
                    "name": "debug_src",
                    "content": "Debug a single doctest docstring, in argument `src`'\n"
                },
                {
                    "name": "register_optionflag",
                    "content": ""
                },
                {
                    "name": "run_docstring_examples",
                    "content": "Test examples in the given object's docstring (`f`), using `globs`\nas globals.  Optional argument `name` is used in failure messages.\nIf the optional argument `verbose` is true, then generate output\neven if there are no failures.\n\n`compileflags` gives the set of flags that should be used by the\nPython compiler when running the examples.  If not specified, then\nit will default to the set of future-import flags that apply to\n`globs`.\n\nOptional keyword arg `optionflags` specifies options for the\ntesting and output.  See the documentation for `testmod` for more\ninformation.\n"
                },
                {
                    "name": "script_from_examples",
                    "content": "Extract script from text with examples.\n\nConverts text with examples to a Python script.  Example input is\nconverted to regular code.  Example output and all other words\nare converted to comments:\n\n>>> text = '''\n...       Here are examples of simple math.\n...\n...           Python has super accurate integer addition\n...\n...           >>> 2 + 2\n...           5\n...\n...           And very friendly error messages:\n...\n...           >>> 1/0\n...           To Infinity\n...           And\n...           Beyond\n...\n...           You can use logic if you want:\n...\n...           >>> if 0:\n...           ...    blah\n...           ...    blah\n...           ...\n...\n...           Ho hum\n...           '''\n\n>>> print(scriptfromexamples(text))\n# Here are examples of simple math.\n#\n#     Python has super accurate integer addition\n#\n2 + 2\n# Expected:\n## 5\n#\n#     And very friendly error messages:\n#\n1/0\n# Expected:\n## To Infinity\n## And\n## Beyond\n#\n#     You can use logic if you want:\n#\nif 0:\nblah\nblah\n#\n#     Ho hum\n<BLANKLINE>\n"
                },
                {
                    "name": "set_unittest_reportflags",
                    "content": "Sets the unittest option flags.\n\nThe old flag is returned so that a runner could restore the old\nvalue if it wished to:\n\n>>> import doctest\n>>> old = doctest.unittestreportflags\n>>> doctest.setunittestreportflags(REPORTNDIFF |\n...                          REPORTONLYFIRSTFAILURE) == old\nTrue\n\n>>> doctest.unittestreportflags == (REPORTNDIFF |\n...                                   REPORTONLYFIRSTFAILURE)\nTrue\n\nOnly reporting flags can be set:\n\n>>> doctest.setunittestreportflags(ELLIPSIS)\nTraceback (most recent call last):\n...\nValueError: ('Only reporting flags allowed', 8)\n\n>>> doctest.setunittestreportflags(old) == (REPORTNDIFF |\n...                                   REPORTONLYFIRSTFAILURE)\nTrue\n"
                },
                {
                    "name": "testfile",
                    "content": "Test examples in the given file.  Return (#failures, #tests).\n\nOptional keyword arg \"modulerelative\" specifies how filenames\nshould be interpreted:\n\n- If \"modulerelative\" is True (the default), then \"filename\"\nspecifies a module-relative path.  By default, this path is\nrelative to the calling module's directory; but if the\n\"package\" argument is specified, then it is relative to that\npackage.  To ensure os-independence, \"filename\" should use\n\"/\" characters to separate path segments, and should not\nbe an absolute path (i.e., it may not begin with \"/\").\n\n- If \"modulerelative\" is False, then \"filename\" specifies an\nos-specific path.  The path may be absolute or relative (to\nthe current working directory).\n\nOptional keyword arg \"name\" gives the name of the test; by default\nuse the file's basename.\n\nOptional keyword argument \"package\" is a Python package or the\nname of a Python package whose directory should be used as the\nbase directory for a module relative filename.  If no package is\nspecified, then the calling module's directory is used as the base\ndirectory for module relative filenames.  It is an error to\nspecify \"package\" if \"modulerelative\" is False.\n\nOptional keyword arg \"globs\" gives a dict to be used as the globals\nwhen executing examples; by default, use {}.  A copy of this dict\nis actually used for each docstring, so that each docstring's\nexamples start with a clean slate.\n\nOptional keyword arg \"extraglobs\" gives a dictionary that should be\nmerged into the globals that are used to execute examples.  By\ndefault, no extra globals are used.\n\nOptional keyword arg \"verbose\" prints lots of stuff if true, prints\nonly failures if false; by default, it's true iff \"-v\" is in sys.argv.\n\nOptional keyword arg \"report\" prints a summary at the end when true,\nelse prints nothing at the end.  In verbose mode, the summary is\ndetailed, else very brief (in fact, empty if all tests passed).\n\nOptional keyword arg \"optionflags\" or's together module constants,\nand defaults to 0.  Possible values (see the docs for details):\n\nDONTACCEPTTRUEFOR1\nDONTACCEPTBLANKLINE\nNORMALIZEWHITESPACE\nELLIPSIS\nSKIP\nIGNOREEXCEPTIONDETAIL\nREPORTUDIFF\nREPORTCDIFF\nREPORTNDIFF\nREPORTONLYFIRSTFAILURE\n\nOptional keyword arg \"raiseonerror\" raises an exception on the\nfirst unexpected exception or failure. This allows failures to be\npost-mortem debugged.\n\nOptional keyword arg \"parser\" specifies a DocTestParser (or\nsubclass) that should be used to extract tests from the files.\n\nOptional keyword arg \"encoding\" specifies an encoding that should\nbe used to convert the file to unicode.\n\nAdvanced tomfoolery:  testmod runs methods of a local instance of\nclass doctest.Tester, then merges the results into (or creates)\nglobal Tester instance doctest.master.  Methods of doctest.master\ncan be called directly too, if you want to do something unusual.\nPassing report=0 to testmod is especially useful then, to delay\ndisplaying a summary.  Invoke doctest.master.summarize(verbose)\nwhen you're done fiddling.\n"
                },
                {
                    "name": "testmod",
                    "content": "m=None, name=None, globs=None, verbose=None, report=True,\noptionflags=0, extraglobs=None, raiseonerror=False,\nexcludeempty=False\n\nTest examples in docstrings in functions and classes reachable\nfrom module m (or the current module if m is not supplied), starting\nwith m.doc.\n\nAlso test examples reachable from dict m.test if it exists and is\nnot None.  m.test maps names to functions, classes and strings;\nfunction and class docstrings are tested even if the name is private;\nstrings are tested directly, as if they were docstrings.\n\nReturn (#failures, #tests).\n\nSee help(doctest) for an overview.\n\nOptional keyword arg \"name\" gives the name of the module; by default\nuse m.name.\n\nOptional keyword arg \"globs\" gives a dict to be used as the globals\nwhen executing examples; by default, use m.dict.  A copy of this\ndict is actually used for each docstring, so that each docstring's\nexamples start with a clean slate.\n\nOptional keyword arg \"extraglobs\" gives a dictionary that should be\nmerged into the globals that are used to execute examples.  By\ndefault, no extra globals are used.  This is new in 2.4.\n\nOptional keyword arg \"verbose\" prints lots of stuff if true, prints\nonly failures if false; by default, it's true iff \"-v\" is in sys.argv.\n\nOptional keyword arg \"report\" prints a summary at the end when true,\nelse prints nothing at the end.  In verbose mode, the summary is\ndetailed, else very brief (in fact, empty if all tests passed).\n\nOptional keyword arg \"optionflags\" or's together module constants,\nand defaults to 0.  This is new in 2.3.  Possible values (see the\ndocs for details):\n\nDONTACCEPTTRUEFOR1\nDONTACCEPTBLANKLINE\nNORMALIZEWHITESPACE\nELLIPSIS\nSKIP\nIGNOREEXCEPTIONDETAIL\nREPORTUDIFF\nREPORTCDIFF\nREPORTNDIFF\nREPORTONLYFIRSTFAILURE\n\nOptional keyword arg \"raiseonerror\" raises an exception on the\nfirst unexpected exception or failure. This allows failures to be\npost-mortem debugged.\n\nAdvanced tomfoolery:  testmod runs methods of a local instance of\nclass doctest.Tester, then merges the results into (or creates)\nglobal Tester instance doctest.master.  Methods of doctest.master\ncan be called directly too, if you want to do something unusual.\nPassing report=0 to testmod is especially useful then, to delay\ndisplaying a summary.  Invoke doctest.master.summarize(verbose)\nwhen you're done fiddling.\n"
                },
                {
                    "name": "testsource",
                    "content": "Extract the test sources from a doctest docstring as a script.\n\nProvide the module (or dotted name of the module) containing the\ntest to be debugged and the name (within the module) of the object\nwith the doc string with tests to be debugged.\n"
                }
            ]
        },
        "DATA": {
            "content": "COMPARISONFLAGS = 63\nDONTACCEPTBLANKLINE = 2\nDONTACCEPTTRUEFOR1 = 1\nELLIPSIS = 8\nFAILFAST = 1024\nIGNOREEXCEPTIONDETAIL = 32\nNORMALIZEWHITESPACE = 4\nREPORTINGFLAGS = 1984\nREPORTCDIFF = 128\nREPORTNDIFF = 256\nREPORTONLYFIRSTFAILURE = 512\nREPORTUDIFF = 64\nSKIP = 16\nall = ['registeroptionflag', 'DONTACCEPTTRUEFOR1', 'DONTACCE...\ndocformat = 'reStructuredText en'\ntest = {'TestClass': <class 'doctest.TestClass'>, 'blank lines':...\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.10/doctest.py\n\n",
            "subsections": []
        }
    },
    "summary": "doctest - Module doctest -- a framework for running examples in docstrings.",
    "flags": [],
    "examples": [],
    "see_also": []
}