chunk_id stringlengths 36 36 | source stringclasses 35
values | source_url stringlengths 0 290 | upstream_license stringclasses 1
value | document_id stringlengths 36 36 | chunk_index int64 0 324k | retrieved_at stringclasses 2
values | chunker_version stringclasses 4
values | content_hash stringlengths 15 64 | content stringlengths 50 44.7k | namespace stringclasses 9
values | source_name stringclasses 35
values | raw_text stringlengths 50 44.7k | cleaned_text stringlengths 50 44.7k | tags stringclasses 49
values | collection_name stringclasses 11
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ae98a7b0-eea2-4b04-9e9d-7c1384965eb1 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,693 | supabase-export-v2 | ad7f2612f2084e8c | not be checked. E.g., the example's output might be random; or the example might depend on resources which would be unavailable to the test driver.
The SKIP flag can also be used for temporarily "commenting out" examples. | trusted_official_docs | CPython Docs | not be checked. E.g., the example's output might be random; or the example might depend on resources which would be unavailable to the test driver.
The SKIP flag can also be used for temporarily "commenting out" examples. | not be checked. E.g., the example's output might be random; or the example might depend on resources which would be unavailable to the test driver.
The SKIP flag can also be used for temporarily "commenting out" examples. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
af5a19cc-8c1f-4cd5-b74d-ceef91b38195 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,762 | supabase-export-v2 | e2dc0eb5ce78df69 | ``False``, then *filename* specifies an OS-specific path. The path may be absolute or relative; relative paths are resolved with respect to the current working directory.
Optional argument *name* gives the name of the test; by default, or if ``None``,
``os.path.basename(filename)`` is used. | trusted_official_docs | CPython Docs | ``False``, then *filename* specifies an OS-specific path. The path may be absolute or relative; relative paths are resolved with respect to the current working directory.
Optional argument *name* gives the name of the test; by default, or if ``None``,
``os.path.basename(filename)`` is used. | ``False``, then *filename* specifies an OS-specific path. The path may be absolute or relative; relative paths are resolved with respect to the current working directory.
Optional argument *name* gives the name of the test; by default, or if ``None``,
``os.path.basename(filename)`` is used. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
aff1e47b-4e3a-4a23-93b7-a8499c2d7bee | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,755 | supabase-export-v2 | a062b28ef7d25af1 | Basic API ---------
The functions :func:`testmod` and :func:`testfile` provide a simple interface to
doctest that should be sufficient for most basic uses. For a less formal
introduction to these two functions, see sections :ref:`doctest-simple-testmod`
and :ref:`doctest-simple-testfile`. | trusted_official_docs | CPython Docs | Basic API ---------
The functions :func:`testmod` and :func:`testfile` provide a simple interface to
doctest that should be sufficient for most basic uses. For a less formal
introduction to these two functions, see sections :ref:`doctest-simple-testmod`
and :ref:`doctest-simple-testfile`. | Basic API ---------
The functions :func:`testmod` and :func:`testfile` provide a simple interface to
doctest that should be sufficient for most basic uses. For a less formal
introduction to these two functions, see sections :ref:`doctest-simple-testmod`
and :ref:`doctest-simple-testfile`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b096472b-0dea-48a0-b4c9-08f37d654b42 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,995 | supabase-export-v2 | 213dfe65650051ad | to testing framework authors, and will only be sketched here. See the source code, and especially :class:`DebugRunner`'s docstring (which is a doctest!) for more details:
.. class:: DebugRunner(checker=None, verbose=None, optionflags=0) | trusted_official_docs | CPython Docs | to testing framework authors, and will only be sketched here. See the source code, and especially :class:`DebugRunner`'s docstring (which is a doctest!) for more details:
.. class:: DebugRunner(checker=None, verbose=None, optionflags=0) | to testing framework authors, and will only be sketched here. See the source code, and especially :class:`DebugRunner`'s docstring (which is a doctest!) for more details:
.. class:: DebugRunner(checker=None, verbose=None, optionflags=0) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b243415f-2051-48a7-9149-2f19926f7f9c | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,779 | supabase-export-v2 | c4ccc9195c36dc92 | Optional argument *name* gives the name of the module; by default, or if ``None``, ``m.__name__`` is used.
Optional argument *exclude_empty* defaults to false. If true, objects for which
no doctests are found are excluded from consideration. The default is a backward
compatibility hack, so that code still using
:met... | trusted_official_docs | CPython Docs | Optional argument *name* gives the name of the module; by default, or if ``None``, ``m.__name__`` is used.
Optional argument *exclude_empty* defaults to false. If true, objects for which
no doctests are found are excluded from consideration. The default is a backward
compatibility hack, so that code still using
:met... | Optional argument *name* gives the name of the module; by default, or if ``None``, ``m.__name__`` is used.
Optional argument *exclude_empty* defaults to false. If true, objects for which
no doctests are found are excluded from consideration. The default is a backward
compatibility hack, so that code still using
:met... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b28bee11-86cb-414e-b07d-1c898673dfb6 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,775 | supabase-export-v2 | 7c2c87d9f50eac2d | examples in docstrings in functions and classes reachable from module *m* (or module :mod:`__main__` if *m* is not supplied or is ``None``), starting with ``m.__doc__``.
Also test examples reachable from dict ``m.__test__``, if it exists. ``m.__test__`` maps names (strings) to functions, classes and
strings; function ... | trusted_official_docs | CPython Docs | examples in docstrings in functions and classes reachable from module *m* (or module :mod:`__main__` if *m* is not supplied or is ``None``), starting with ``m.__doc__``.
Also test examples reachable from dict ``m.__test__``, if it exists. ``m.__test__`` maps names (strings) to functions, classes and
strings; function ... | examples in docstrings in functions and classes reachable from module *m* (or module :mod:`__main__` if *m* is not supplied or is ``None``), starting with ``m.__doc__``.
Also test examples reachable from dict ``m.__test__``, if it exists. ``m.__test__`` maps names (strings) to functions, classes and
strings; function ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b47edd8c-c8e2-4ddf-9e2c-0f4497f19c26 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,925 | supabase-export-v2 | 5b36f9911e6e5723 | that the given example was skipped. This method is provided to allow subclasses of :class:`DocTestRunner` to customize their output; it should not be called directly.
*example* is the example about to be processed. *test* is the test
containing *example*. *out* is the output function that was passed to
:meth:`DocTest... | trusted_official_docs | CPython Docs | that the given example was skipped. This method is provided to allow subclasses of :class:`DocTestRunner` to customize their output; it should not be called directly.
*example* is the example about to be processed. *test* is the test
containing *example*. *out* is the output function that was passed to
:meth:`DocTest... | that the given example was skipped. This method is provided to allow subclasses of :class:`DocTestRunner` to customize their output; it should not be called directly.
*example* is the example about to be processed. *test* is the test
containing *example*. *out* is the output function that was passed to
:meth:`DocTest... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
badcbf24-8e41-4098-bfae-edaed0e10fc2 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,896 | supabase-export-v2 | eb83192e45937fb0 | cannot be found automatically, then all objects are considered to belong to the (non-existent) module, so all contained objects will (recursively) be searched for doctests.
The globals for each :class:`DocTest` is formed by combining *globs* and
*extraglobs* (bindings in *extraglobs* override bindings in *globs*). A n... | trusted_official_docs | CPython Docs | cannot be found automatically, then all objects are considered to belong to the (non-existent) module, so all contained objects will (recursively) be searched for doctests.
The globals for each :class:`DocTest` is formed by combining *globs* and
*extraglobs* (bindings in *extraglobs* override bindings in *globs*). A n... | cannot be found automatically, then all objects are considered to belong to the (non-existent) module, so all contained objects will (recursively) be searched for doctests.
The globals for each :class:`DocTest` is formed by combining *globs* and
*extraglobs* (bindings in *extraglobs* override bindings in *globs*). A n... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
baf42a57-4696-440b-a217-08c8831c258e | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,613 | supabase-export-v2 | a5163211f5ac8104 | .. currentmodule:: doctest
In addition, there are cases when you want tests to be part of a module but not part
of the help text, which requires that the tests not be included in the docstring. Doctest looks for a module-level variable called ``__test__`` and uses it to locate other
tests. If ``M.__test__`` exists, it ... | trusted_official_docs | CPython Docs | .. currentmodule:: doctest
In addition, there are cases when you want tests to be part of a module but not part
of the help text, which requires that the tests not be included in the docstring. Doctest looks for a module-level variable called ``__test__`` and uses it to locate other
tests. If ``M.__test__`` exists, it ... | .. currentmodule:: doctest
In addition, there are cases when you want tests to be part of a module but not part
of the help text, which requires that the tests not be included in the docstring. Doctest looks for a module-level variable called ``__test__`` and uses it to locate other
tests. If ``M.__test__`` exists, it ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bb670f3f-4e03-4538-be31-edba4f6dbcad | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,746 | supabase-export-v2 | 7549b256e8576d85 | doctest: +SKIP 7948648 >>> class C: pass >>> C() # the default repr() for instances embeds an address # doctest: +SKIP <C object at 0x00AC18F0>
The :const:`ELLIPSIS` directive gives a nice approach for the last example: | trusted_official_docs | CPython Docs | doctest: +SKIP 7948648 >>> class C: pass >>> C() # the default repr() for instances embeds an address # doctest: +SKIP <C object at 0x00AC18F0>
The :const:`ELLIPSIS` directive gives a nice approach for the last example: | doctest: +SKIP 7948648 >>> class C: pass >>> C() # the default repr() for instances embeds an address # doctest: +SKIP <C object at 0x00AC18F0>
The :const:`ELLIPSIS` directive gives a nice approach for the last example: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bc05718f-b0c7-4937-a06f-5f55f83c9dd7 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,722 | supabase-export-v2 | f59db36652d87200 | >>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
Without the directive it would fail, both because the actual output doesn't have
two blanks before the single-digit list elements, and because the actual output
is on a single line. This te... | trusted_official_docs | CPython Docs | >>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
Without the directive it would fail, both because the actual output doesn't have
two blanks before the single-digit list elements, and because the actual output
is on a single line. This te... | >>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
Without the directive it would fail, both because the actual output doesn't have
two blanks before the single-digit list elements, and because the actual output
is on a single line. This te... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bc1186bb-6ed4-4cf3-b9ac-9c19b1e378da | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,769 | supabase-export-v2 | 9b1cec54bdfdf729 | Optional argument *optionflags* (default value ``0``) takes the :ref:`bitwise OR <bitwise>` of option flags. See section :ref:`doctest-options`.
Optional argument *raise_on_error* defaults to false. If true, an exception is
raised upon the first failure or unexpected exception in an example. This
allows failures to b... | trusted_official_docs | CPython Docs | Optional argument *optionflags* (default value ``0``) takes the :ref:`bitwise OR <bitwise>` of option flags. See section :ref:`doctest-options`.
Optional argument *raise_on_error* defaults to false. If true, an exception is
raised upon the first failure or unexpected exception in an example. This
allows failures to b... | Optional argument *optionflags* (default value ``0``) takes the :ref:`bitwise OR <bitwise>` of option flags. See section :ref:`doctest-options`.
Optional argument *raise_on_error* defaults to false. If true, an exception is
raised upon the first failure or unexpected exception in an example. This
allows failures to b... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bcbdf3bc-ed5b-4098-b2ef-c28a7bcc1b7c | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,959 | supabase-export-v2 | ca1818de49b7323d | on what option flags the test runner is using, several non-exact match types are also possible. See section :ref:`doctest-options` for more information about option flags.
.. method:: output_difference(example, got, optionflags) | trusted_official_docs | CPython Docs | on what option flags the test runner is using, several non-exact match types are also possible. See section :ref:`doctest-options` for more information about option flags.
.. method:: output_difference(example, got, optionflags) | on what option flags the test runner is using, several non-exact match types are also possible. See section :ref:`doctest-options` for more information about option flags.
.. method:: output_difference(example, got, optionflags) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bd5be8b0-ceea-4254-a9e2-efbff87611f6 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,877 | supabase-export-v2 | 429bcd9a6fd21c4d | .. attribute:: options
A dictionary mapping from option flags to ``True`` or ``False``, which is used
to override default options for this example. Any option flags not contained
in this dictionary are left at their default value (as specified by the
:class:`DocTestRunner`'s :ref:`optionflags <doctest-options>`). By... | trusted_official_docs | CPython Docs | .. attribute:: options
A dictionary mapping from option flags to ``True`` or ``False``, which is used
to override default options for this example. Any option flags not contained
in this dictionary are left at their default value (as specified by the
:class:`DocTestRunner`'s :ref:`optionflags <doctest-options>`). By... | .. attribute:: options
A dictionary mapping from option flags to ``True`` or ``False``, which is used
to override default options for this example. Any option flags not contained
in this dictionary are left at their default value (as specified by the
:class:`DocTestRunner`'s :ref:`optionflags <doctest-options>`). By... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bdf1e2b5-9d56-465b-b556-78eb407e5d9d | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,619 | supabase-export-v2 | 5edaff53727c35aa | value can be mapped to a function, class object, or module; if so, :mod:`!doctest` searches them recursively for docstrings, which are then scanned for tests.
Any classes found are recursively searched similarly, to test docstrings in
their contained methods and nested classes. | trusted_official_docs | CPython Docs | value can be mapped to a function, class object, or module; if so, :mod:`!doctest` searches them recursively for docstrings, which are then scanned for tests.
Any classes found are recursively searched similarly, to test docstrings in
their contained methods and nested classes. | value can be mapped to a function, class object, or module; if so, :mod:`!doctest` searches them recursively for docstrings, which are then scanned for tests.
Any classes found are recursively searched similarly, to test docstrings in
their contained methods and nested classes. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
be273b08-a508-4bf1-b079-8405427e7ca1 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,684 | supabase-export-v2 | d90c6ba3c40fc3fd | exceptions pass so long as an exception of the expected type is raised, even if the details (message and fully qualified exception name) don't match.
For example, an example expecting ``ValueError: 42`` will pass if the actual
exception raised is ``ValueError: 3*14``, but will fail if, say, a
:exc:`TypeError` is rais... | trusted_official_docs | CPython Docs | exceptions pass so long as an exception of the expected type is raised, even if the details (message and fully qualified exception name) don't match.
For example, an example expecting ``ValueError: 42`` will pass if the actual
exception raised is ``ValueError: 3*14``, but will fail if, say, a
:exc:`TypeError` is rais... | exceptions pass so long as an exception of the expected type is raised, even if the details (message and fully qualified exception name) don't match.
For example, an example expecting ``ValueError: 42`` will pass if the actual
exception raised is ``ValueError: 3*14``, but will fail if, say, a
:exc:`TypeError` is rais... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bf1fe655-6392-4054-a1b4-40dca977a223 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,622 | supabase-export-v2 | 31440b8a3ebc2323 | ``doctest`` can only automatically discover classes and functions that are defined at the module level or inside other classes.
Since nested classes and functions only exist when an outer function
is called, they cannot be discovered. Define them outside to make them visible. | trusted_official_docs | CPython Docs | ``doctest`` can only automatically discover classes and functions that are defined at the module level or inside other classes.
Since nested classes and functions only exist when an outer function
is called, they cannot be discovered. Define them outside to make them visible. | ``doctest`` can only automatically discover classes and functions that are defined at the module level or inside other classes.
Since nested classes and functions only exist when an outer function
is called, they cannot be discovered. Define them outside to make them visible. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c197368f-769d-4f8c-9288-c7378279cb22 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,661 | supabase-export-v2 | 33f4552853197c5d | Some details you should read once, but won't need to remember:
* Doctest can't guess whether your expected output came from an exception
traceback or from ordinary printing. So, e.g., an example that expects
``ValueError: 42 is prime`` will pass whether :exc:`ValueError` is actually
raised or if the example merely p... | trusted_official_docs | CPython Docs | Some details you should read once, but won't need to remember:
* Doctest can't guess whether your expected output came from an exception
traceback or from ordinary printing. So, e.g., an example that expects
``ValueError: 42 is prime`` will pass whether :exc:`ValueError` is actually
raised or if the example merely p... | Some details you should read once, but won't need to remember:
* Doctest can't guess whether your expected output came from an exception
traceback or from ordinary printing. So, e.g., an example that expects
``ValueError: 42 is prime`` will pass whether :exc:`ValueError` is actually
raised or if the example merely p... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c5afae9e-5552-4cbc-a75d-ed51cef4ced7 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,677 | supabase-export-v2 | e8e7e2d2a88efdd4 | .. index:: single: <BLANKLINE> .. data:: DONT_ACCEPT_BLANKLINE
By default, if an expected output block contains a line containing only the
string ``<BLANKLINE>``, then that line will match a blank line in the actual
output. Because a genuinely blank line delimits the expected output, this is
the only way to communic... | trusted_official_docs | CPython Docs | .. index:: single: <BLANKLINE> .. data:: DONT_ACCEPT_BLANKLINE
By default, if an expected output block contains a line containing only the
string ``<BLANKLINE>``, then that line will match a blank line in the actual
output. Because a genuinely blank line delimits the expected output, this is
the only way to communic... | .. index:: single: <BLANKLINE> .. data:: DONT_ACCEPT_BLANKLINE
By default, if an expected output block contains a line containing only the
string ``<BLANKLINE>``, then that line will match a blank line in the actual
output. Because a genuinely blank line delimits the expected output, this is
the only way to communic... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c6914596-222a-482a-9dd0-c9df98798e79 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,546 | supabase-export-v2 | 08be6774d6bdc9cd | value like 1e300 raise OverflowError("n too large") result = 1 factor = 2 while factor <= n: result *= factor factor += 1 return result
if __name__ == "__main__":
import doctest
doctest.testmod() | trusted_official_docs | CPython Docs | value like 1e300 raise OverflowError("n too large") result = 1 factor = 2 while factor <= n: result *= factor factor += 1 return result
if __name__ == "__main__":
import doctest
doctest.testmod() | value like 1e300 raise OverflowError("n too large") result = 1 factor = 2 while factor <= n: result *= factor factor += 1 return result
if __name__ == "__main__":
import doctest
doctest.testmod() | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c77d25ec-9434-4dde-808a-d058902f89c1 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,869 | supabase-export-v2 | cdffe525e9b4371c | .. attribute:: want
The expected output from running the example's source code (either from
stdout, or a traceback in case of exception). :attr:`want` ends with a
newline unless no output is expected, in which case it's an empty string. The
constructor adds a newline when necessary. | trusted_official_docs | CPython Docs | .. attribute:: want
The expected output from running the example's source code (either from
stdout, or a traceback in case of exception). :attr:`want` ends with a
newline unless no output is expected, in which case it's an empty string. The
constructor adds a newline when necessary. | .. attribute:: want
The expected output from running the example's source code (either from
stdout, or a traceback in case of exception). :attr:`want` ends with a
newline unless no output is expected, in which case it's an empty string. The
constructor adds a newline when necessary. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
caaaf1c2-77a2-4d5e-896b-dd56fdb7394f | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,830 | supabase-export-v2 | f6a8b8ac7cfa5b50 | :class:`DocTestRunner` instance created to run the doctest. If any reporting flags were specified when the :class:`!DocTestCase` instance was constructed, :mod:`!doctest`'s :mod:`!unittest` reporting flags are ignored.
The value of the :mod:`unittest` reporting flags in effect before the function
was called is returne... | trusted_official_docs | CPython Docs | :class:`DocTestRunner` instance created to run the doctest. If any reporting flags were specified when the :class:`!DocTestCase` instance was constructed, :mod:`!doctest`'s :mod:`!unittest` reporting flags are ignored.
The value of the :mod:`unittest` reporting flags in effect before the function
was called is returne... | :class:`DocTestRunner` instance created to run the doctest. If any reporting flags were specified when the :class:`!DocTestCase` instance was constructed, :mod:`!doctest`'s :mod:`!unittest` reporting flags are ignored.
The value of the :mod:`unittest` reporting flags in effect before the function
was called is returne... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cb6b206a-4391-4823-9119-300defab0d54 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,823 | supabase-export-v2 | 565d8a5aa6a35162 | subclass of :class:`unittest.TestCase`. :class:`!DocTestCase` isn't documented here (it's an internal detail), but studying its code can answer questions about the exact details of :mod:`unittest` integration.
Similarly, :func:`DocFileSuite` creates a :class:`unittest.TestSuite` out of
:class:`!doctest.DocFileCase` ins... | trusted_official_docs | CPython Docs | subclass of :class:`unittest.TestCase`. :class:`!DocTestCase` isn't documented here (it's an internal detail), but studying its code can answer questions about the exact details of :mod:`unittest` integration.
Similarly, :func:`DocFileSuite` creates a :class:`unittest.TestSuite` out of
:class:`!doctest.DocFileCase` ins... | subclass of :class:`unittest.TestCase`. :class:`!DocTestCase` isn't documented here (it's an internal detail), but studying its code can answer questions about the exact details of :mod:`unittest` integration.
Similarly, :func:`DocFileSuite` creates a :class:`unittest.TestSuite` out of
:class:`!doctest.DocFileCase` ins... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cbde7a76-8457-47e1-a2b0-7145ff3513ae | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,815 | supabase-export-v2 | 23a7854a6f1a65c2 | to be tested. It can be a module object or a (possibly dotted) module name. If not specified, the module calling this function is used.
Optional argument *globs* is a dictionary containing the initial global
variables for the tests. A new copy of this dictionary is created for each
test. By default, *globs* is the mo... | trusted_official_docs | CPython Docs | to be tested. It can be a module object or a (possibly dotted) module name. If not specified, the module calling this function is used.
Optional argument *globs* is a dictionary containing the initial global
variables for the tests. A new copy of this dictionary is created for each
test. By default, *globs* is the mo... | to be tested. It can be a module object or a (possibly dotted) module name. If not specified, the module calling this function is used.
Optional argument *globs* is a dictionary containing the initial global
variables for the tests. A new copy of this dictionary is created for each
test. By default, *globs* is the mo... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ccb159d5-e289-4f39-b1f4-cb5475f9c907 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 32,033 | supabase-export-v2 | be9caff67e7814e0 | .. rubric:: Footnotes
.. [#] Examples containing both expected output and an exception are not supported. Trying to guess where one ends and the other begins is too error-prone, and that
also makes for a confusing test. | trusted_official_docs | CPython Docs | .. rubric:: Footnotes
.. [#] Examples containing both expected output and an exception are not supported. Trying to guess where one ends and the other begins is too error-prone, and that
also makes for a confusing test. | .. rubric:: Footnotes
.. [#] Examples containing both expected output and an exception are not supported. Trying to guess where one ends and the other begins is too error-prone, and that
also makes for a confusing test. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ccfadc4f-9fbe-47d0-86cf-ce8bae19694d | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,781 | supabase-export-v2 | 4297621723f73d49 | Optional arguments *extraglobs*, *verbose*, *report*, *optionflags*, *raise_on_error*, and *globs* are the same as for function :func:`testfile` above, except that *globs* defaults to ``m.__dict__``.
.. function:: run_docstring_examples(f, globs, verbose=False, name="NoName", compileflags=None, optionflags=0) | trusted_official_docs | CPython Docs | Optional arguments *extraglobs*, *verbose*, *report*, *optionflags*, *raise_on_error*, and *globs* are the same as for function :func:`testfile` above, except that *globs* defaults to ``m.__dict__``.
.. function:: run_docstring_examples(f, globs, verbose=False, name="NoName", compileflags=None, optionflags=0) | Optional arguments *extraglobs*, *verbose*, *report*, *optionflags*, *raise_on_error*, and *globs* are the same as for function :func:`testfile` above, except that *globs* defaults to ``m.__dict__``.
.. function:: run_docstring_examples(f, globs, verbose=False, name="NoName", compileflags=None, optionflags=0) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d02d073e-d426-4d67-8c40-58a358b6a7a6 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,542 | supabase-export-v2 | 99cc22f4fcff11ee | def factorial(n): """Return the factorial of n, an exact integer >= 0.
>>> [factorial(n) for n in range(6)]
[1, 1, 2, 6, 24, 120]
>>> factorial(30)
265252859812191058636308480000000
>>> factorial(-1)
Traceback (most recent call last):
... ValueError: n must be >= 0 | trusted_official_docs | CPython Docs | def factorial(n): """Return the factorial of n, an exact integer >= 0.
>>> [factorial(n) for n in range(6)]
[1, 1, 2, 6, 24, 120]
>>> factorial(30)
265252859812191058636308480000000
>>> factorial(-1)
Traceback (most recent call last):
... ValueError: n must be >= 0 | def factorial(n): """Return the factorial of n, an exact integer >= 0.
>>> [factorial(n) for n in range(6)]
[1, 1, 2, 6, 24, 120]
>>> factorial(30)
265252859812191058636308480000000
>>> factorial(-1)
Traceback (most recent call last):
... ValueError: n must be >= 0 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d0c2a126-959b-4277-9dcb-b7e4ad241a68 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,822 | supabase-export-v2 | 3cbddd0ac0f3cbff | .. versionchanged:: 3.15 Run each example as a :ref:`subtest <subtests>`.
Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` out
of :class:`!doctest.DocTestCase` instances, and :class:`!DocTestCase` is a
subclass of :class:`unittest.TestCase`. :class:`!DocTestCase` isn't documented
here (it's ... | trusted_official_docs | CPython Docs | .. versionchanged:: 3.15 Run each example as a :ref:`subtest <subtests>`.
Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` out
of :class:`!doctest.DocTestCase` instances, and :class:`!DocTestCase` is a
subclass of :class:`unittest.TestCase`. :class:`!DocTestCase` isn't documented
here (it's ... | .. versionchanged:: 3.15 Run each example as a :ref:`subtest <subtests>`.
Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` out
of :class:`!doctest.DocTestCase` instances, and :class:`!DocTestCase` is a
subclass of :class:`unittest.TestCase`. :class:`!DocTestCase` isn't documented
here (it's ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d205b79e-ed0f-4d9d-9417-0151e536aa9a | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,987 | supabase-export-v2 | 48fc29a8ab630182 | for the named object's docstring is written to a temporary file, and then that file is run under the control of the Python debugger, :mod:`pdb`.
A shallow copy of ``module.__dict__`` is used for both local and global
execution context. | trusted_official_docs | CPython Docs | for the named object's docstring is written to a temporary file, and then that file is run under the control of the Python debugger, :mod:`pdb`.
A shallow copy of ``module.__dict__`` is used for both local and global
execution context. | for the named object's docstring is written to a temporary file, and then that file is run under the control of the Python debugger, :mod:`pdb`.
A shallow copy of ``module.__dict__`` is used for both local and global
execution context. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d291c991-df27-4ba4-9cb1-f5f40be78a0c | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,672 | supabase-export-v2 | 916265006d9bd7da | Option Flags ^^^^^^^^^^^^
A number of option flags control various aspects of doctest's behavior. Symbolic names for the flags are supplied as module constants, which can be
:ref:`bitwise ORed <bitwise>` together and passed to various functions. The names can also be used in :ref:`doctest directives <doctest-directives... | trusted_official_docs | CPython Docs | Option Flags ^^^^^^^^^^^^
A number of option flags control various aspects of doctest's behavior. Symbolic names for the flags are supplied as module constants, which can be
:ref:`bitwise ORed <bitwise>` together and passed to various functions. The names can also be used in :ref:`doctest directives <doctest-directives... | Option Flags ^^^^^^^^^^^^
A number of option flags control various aspects of doctest's behavior. Symbolic names for the flags are supplied as module constants, which can be
:ref:`bitwise ORed <bitwise>` together and passed to various functions. The names can also be used in :ref:`doctest directives <doctest-directives... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d2ab671a-fb83-4273-93ba-33a776e82e6a | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,856 | supabase-export-v2 | 2f048343c7f352da | .. attribute:: filename
The name of the file that this :class:`DocTest` was extracted from; or
``None`` if the filename is unknown, or if the :class:`!DocTest` was not
extracted from a file. | trusted_official_docs | CPython Docs | .. attribute:: filename
The name of the file that this :class:`DocTest` was extracted from; or
``None`` if the filename is unknown, or if the :class:`!DocTest` was not
extracted from a file. | .. attribute:: filename
The name of the file that this :class:`DocTest` was extracted from; or
``None`` if the filename is unknown, or if the :class:`!DocTest` was not
extracted from a file. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d3a47e66-99ed-4215-adaa-74fe22d491b1 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,761 | supabase-export-v2 | c4316d5eefc1b26f | ensure OS-independence, *filename* should use ``/`` characters to separate path segments, and may not be an absolute path (i.e., it may not begin with ``/``).
* If *module_relative* is ``False``, then *filename* specifies an OS-specific
path. The path may be absolute or relative; relative paths are resolved with
resp... | trusted_official_docs | CPython Docs | ensure OS-independence, *filename* should use ``/`` characters to separate path segments, and may not be an absolute path (i.e., it may not begin with ``/``).
* If *module_relative* is ``False``, then *filename* specifies an OS-specific
path. The path may be absolute or relative; relative paths are resolved with
resp... | ensure OS-independence, *filename* should use ``/`` characters to separate path segments, and may not be an absolute path (i.e., it may not begin with ``/``).
* If *module_relative* is ``False``, then *filename* specifies an OS-specific
path. The path may be absolute or relative; relative paths are resolved with
resp... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d3b085ee-4f2d-4296-bc2f-7f9efe5189ea | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,938 | supabase-export-v2 | 7a674293c2253d38 | given example raised an unexpected exception. This method is provided to allow subclasses of :class:`DocTestRunner` to customize their output; it should not be called directly.
*example* is the example about to be processed. *exc_info* is a tuple
containing information about the unexpected exception (as returned by
:... | trusted_official_docs | CPython Docs | given example raised an unexpected exception. This method is provided to allow subclasses of :class:`DocTestRunner` to customize their output; it should not be called directly.
*example* is the example about to be processed. *exc_info* is a tuple
containing information about the unexpected exception (as returned by
:... | given example raised an unexpected exception. This method is provided to allow subclasses of :class:`DocTestRunner` to customize their output; it should not be called directly.
*example* is the example about to be processed. *exc_info* is a tuple
containing information about the unexpected exception (as returned by
:... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d440e8e6-e562-4381-91ba-297e135f17fe | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,584 | supabase-export-v2 | 6ff8e7bc7c53823d | File "./example.txt", line 14, in example.txt Failed example: factorial(6) Expected: 120 Got: 720
As with :func:`testmod`, :func:`testfile` won't display anything unless an
example fails. If an example does fail, then the failing example(s) and the
cause(s) of the failure(s) are printed to stdout, using the same format... | trusted_official_docs | CPython Docs | File "./example.txt", line 14, in example.txt Failed example: factorial(6) Expected: 120 Got: 720
As with :func:`testmod`, :func:`testfile` won't display anything unless an
example fails. If an example does fail, then the failing example(s) and the
cause(s) of the failure(s) are printed to stdout, using the same format... | File "./example.txt", line 14, in example.txt Failed example: factorial(6) Expected: 120 Got: 720
As with :func:`testmod`, :func:`testfile` won't display anything unless an
example fails. If an example does fail, then the failing example(s) and the
cause(s) of the failure(s) are printed to stdout, using the same format... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d7ce2f59-5d69-4063-a664-65b9279e8545 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,895 | supabase-export-v2 | 8a9bd2a6e8202ee5 | * To help find the line number of the object within its file.
If *module* is ``False``, no attempt to find the module will be made. This is
obscure, of use mostly in testing doctest itself: if *module* is ``False``, or
is ``None`` but cannot be found automatically, then all objects are considered
to belong to the (n... | trusted_official_docs | CPython Docs | * To help find the line number of the object within its file.
If *module* is ``False``, no attempt to find the module will be made. This is
obscure, of use mostly in testing doctest itself: if *module* is ``False``, or
is ``None`` but cannot be found automatically, then all objects are considered
to belong to the (n... | * To help find the line number of the object within its file.
If *module* is ``False``, no attempt to find the module will be made. This is
obscure, of use mostly in testing doctest itself: if *module* is ``False``, or
is ``None`` but cannot be found automatically, then all objects are considered
to belong to the (n... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d8198f2c-8842-4bb7-9108-5f33cb710839 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,597 | supabase-export-v2 | 6d287fbb655040b6 | python -m doctest -v example.py
This will import :file:`example.py` as a standalone module and run
:func:`testmod` on it. Note that this may not work correctly if the
file is part of a package and imports other submodules from that package. | trusted_official_docs | CPython Docs | python -m doctest -v example.py
This will import :file:`example.py` as a standalone module and run
:func:`testmod` on it. Note that this may not work correctly if the
file is part of a package and imports other submodules from that package. | python -m doctest -v example.py
This will import :file:`example.py` as a standalone module and run
:func:`testmod` on it. Note that this may not work correctly if the
file is part of a package and imports other submodules from that package. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d9693e8c-354f-45fd-8f3b-6992ac647f8c | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,841 | supabase-export-v2 | be3e836c192e400b | * :class:`DocTestRunner`: Executes the examples in a :class:`DocTest`, and uses an :class:`OutputChecker` to verify their output.
* :class:`OutputChecker`: Compares the actual output from a doctest example with
the expected output, and decides whether they match. | trusted_official_docs | CPython Docs | * :class:`DocTestRunner`: Executes the examples in a :class:`DocTest`, and uses an :class:`OutputChecker` to verify their output.
* :class:`OutputChecker`: Compares the actual output from a doctest example with
the expected output, and decides whether they match. | * :class:`DocTestRunner`: Executes the examples in a :class:`DocTest`, and uses an :class:`OutputChecker` to verify their output.
* :class:`OutputChecker`: Compares the actual output from a doctest example with
the expected output, and decides whether they match. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
db0a26f1-f260-4f02-9e09-e519f61c584a | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,650 | supabase-export-v2 | 149f2e8d688fdbd1 | >>> [1, 2, 3].remove(42) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: list.remove(x): x not in list
That doctest succeeds if :exc:`ValueError` is raised, with the ``list.remove(x):
x not in list`` detail as shown. | trusted_official_docs | CPython Docs | >>> [1, 2, 3].remove(42) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: list.remove(x): x not in list
That doctest succeeds if :exc:`ValueError` is raised, with the ``list.remove(x):
x not in list`` detail as shown. | >>> [1, 2, 3].remove(42) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: list.remove(x): x not in list
That doctest succeeds if :exc:`ValueError` is raised, with the ``list.remove(x):
x not in list`` detail as shown. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dc26a407-5de1-41a9-9c2a-2d63deb270d6 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,852 | supabase-export-v2 | e291fcfdee174b02 | .. attribute:: globs
The namespace (aka globals) that the examples should be run in. This is a
dictionary mapping names to values. Any changes to the namespace made by the
examples (such as binding new variables) will be reflected in :attr:`globs`
after the test is run. | trusted_official_docs | CPython Docs | .. attribute:: globs
The namespace (aka globals) that the examples should be run in. This is a
dictionary mapping names to values. Any changes to the namespace made by the
examples (such as binding new variables) will be reflected in :attr:`globs`
after the test is run. | .. attribute:: globs
The namespace (aka globals) that the examples should be run in. This is a
dictionary mapping names to values. Any changes to the namespace made by the
examples (such as binding new variables) will be reflected in :attr:`globs`
after the test is run. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dc89963d-eced-4971-81a2-4fdba420594d | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,941 | supabase-export-v2 | c6af2eb8d7903bae | Run the examples in *test* (a :class:`DocTest` object), and display the results using the writer function *out*. Return a :class:`TestResults` instance.
The examples are run in the namespace ``test.globs``. If *clear_globs* is
true (the default), then this namespace will be cleared after the test runs,
to help with g... | trusted_official_docs | CPython Docs | Run the examples in *test* (a :class:`DocTest` object), and display the results using the writer function *out*. Return a :class:`TestResults` instance.
The examples are run in the namespace ``test.globs``. If *clear_globs* is
true (the default), then this namespace will be cleared after the test runs,
to help with g... | Run the examples in *test* (a :class:`DocTest` object), and display the results using the writer function *out*. Return a :class:`TestResults` instance.
The examples are run in the namespace ``test.globs``. If *clear_globs* is
true (the default), then this namespace will be cleared after the test runs,
to help with g... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dc8fd72a-9f1a-4ce6-a47d-5565f4bac8fd | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,848 | supabase-export-v2 | 71e1bd5e5775495b | collection of doctest examples that should be run in a single namespace. The constructor arguments are used to initialize the attributes of the same names.
:class:`DocTest` defines the following attributes. They are initialized by
the constructor, and should not be modified directly. | trusted_official_docs | CPython Docs | collection of doctest examples that should be run in a single namespace. The constructor arguments are used to initialize the attributes of the same names.
:class:`DocTest` defines the following attributes. They are initialized by
the constructor, and should not be modified directly. | collection of doctest examples that should be run in a single namespace. The constructor arguments are used to initialize the attributes of the same names.
:class:`DocTest` defines the following attributes. They are initialized by
the constructor, and should not be modified directly. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dcbc18d4-97b1-4777-808e-c72d3d5e8f5d | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,690 | supabase-export-v2 | 37bec9b92ddc7c1c | ignore the details of the exception message, but such a test may still fail based on whether the module name is present or matches exactly.
.. versionchanged:: 3.2
:const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating
to the module containing the exception under test. | trusted_official_docs | CPython Docs | ignore the details of the exception message, but such a test may still fail based on whether the module name is present or matches exactly.
.. versionchanged:: 3.2
:const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating
to the module containing the exception under test. | ignore the details of the exception message, but such a test may still fail based on whether the module name is present or matches exactly.
.. versionchanged:: 3.2
:const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating
to the module containing the exception under test. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dd7cc39d-f9e1-4971-b8b1-68a231e8ceea | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,627 | supabase-export-v2 | a2b1f446f6370006 | ::
>>> # comments are ignored
>>> x = 12
>>> x
12
>>> if x == 13:
... print("yes")
... else:
... print("no")
... print("NO")
... print("NO!!!")
... no
NO
NO!!! >>> | trusted_official_docs | CPython Docs | ::
>>> # comments are ignored
>>> x = 12
>>> x
12
>>> if x == 13:
... print("yes")
... else:
... print("no")
... print("NO")
... print("NO!!!")
... no
NO
NO!!! >>> | ::
>>> # comments are ignored
>>> x = 12
>>> x
12
>>> if x == 13:
... print("yes")
... else:
... print("no")
... print("NO")
... print("NO!!!")
... no
NO
NO!!! >>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
de748590-ffa3-4456-87a1-5929075aec8e | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,536 | supabase-export-v2 | 6af1708354457b39 | * To perform regression testing by verifying that interactive examples from a test file or a test object work as expected.
* To write tutorial documentation for a package, liberally illustrated with
input-output examples. Depending on whether the examples or the expository text
are emphasized, this has the flavor of ... | trusted_official_docs | CPython Docs | * To perform regression testing by verifying that interactive examples from a test file or a test object work as expected.
* To write tutorial documentation for a package, liberally illustrated with
input-output examples. Depending on whether the examples or the expository text
are emphasized, this has the flavor of ... | * To perform regression testing by verifying that interactive examples from a test file or a test object work as expected.
* To write tutorial documentation for a package, liberally illustrated with
input-output examples. Depending on whether the examples or the expository text
are emphasized, this has the flavor of ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
de81dc2f-1ebb-430b-94f6-900b0d9cb603 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,891 | supabase-export-v2 | 81c572533d8a4356 | the module is not specified or is ``None``, then the test finder will attempt to automatically determine the correct module. The object's module is used:
* As a default namespace, if *globs* is not specified. | trusted_official_docs | CPython Docs | the module is not specified or is ``None``, then the test finder will attempt to automatically determine the correct module. The object's module is used:
* As a default namespace, if *globs* is not specified. | the module is not specified or is ``None``, then the test finder will attempt to automatically determine the correct module. The object's module is used:
* As a default namespace, if *globs* is not specified. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e0f5decd-1888-45b3-8adc-776c530cf7f3 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,939 | supabase-export-v2 | 7228274d33656d23 | information about the unexpected exception (as returned by :func:`sys.exc_info`). *test* is the test containing *example*. *out* is the output function that was passed to :meth:`DocTestRunner.run`.
.. method:: run(test, compileflags=None, out=None, clear_globs=True) | trusted_official_docs | CPython Docs | information about the unexpected exception (as returned by :func:`sys.exc_info`). *test* is the test containing *example*. *out* is the output function that was passed to :meth:`DocTestRunner.run`.
.. method:: run(test, compileflags=None, out=None, clear_globs=True) | information about the unexpected exception (as returned by :func:`sys.exc_info`). *test* is the test containing *example*. *out* is the output function that was passed to :meth:`DocTestRunner.run`.
.. method:: run(test, compileflags=None, out=None, clear_globs=True) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e16e6aa5-2590-4929-ba43-c6bbff4b3e79 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,756 | supabase-export-v2 | 928715197b7bb776 | interface to doctest that should be sufficient for most basic uses. For a less formal introduction to these two functions, see sections :ref:`doctest-simple-testmod` and :ref:`doctest-simple-testfile`.
.. function:: testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True,... | trusted_official_docs | CPython Docs | interface to doctest that should be sufficient for most basic uses. For a less formal introduction to these two functions, see sections :ref:`doctest-simple-testmod` and :ref:`doctest-simple-testfile`.
.. function:: testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True,... | interface to doctest that should be sufficient for most basic uses. For a less formal introduction to these two functions, see sections :ref:`doctest-simple-testmod` and :ref:`doctest-simple-testfile`.
.. function:: testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True,... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e1e27e36-ef50-4531-b33f-097d6ab84622 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,731 | supabase-export-v2 | c453028a30bd05c5 | >>> print(list(range(20))) # doctest: +ELLIPSIS ... # doctest: +NORMALIZE_WHITESPACE [0, 1, ..., 18, 19]
As the previous example shows, you can add ``...`` lines to your example
containing only directives. This can be useful when an example is too long for
a directive to comfortably fit on the same line: | trusted_official_docs | CPython Docs | >>> print(list(range(20))) # doctest: +ELLIPSIS ... # doctest: +NORMALIZE_WHITESPACE [0, 1, ..., 18, 19]
As the previous example shows, you can add ``...`` lines to your example
containing only directives. This can be useful when an example is too long for
a directive to comfortably fit on the same line: | >>> print(list(range(20))) # doctest: +ELLIPSIS ... # doctest: +NORMALIZE_WHITESPACE [0, 1, ..., 18, 19]
As the previous example shows, you can add ``...`` lines to your example
containing only directives. This can be useful when an example is too long for
a directive to comfortably fit on the same line: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e25d527f-1d84-4a13-a4cb-cbd398e8a035 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,994 | supabase-export-v2 | 164d98da98576c8c | local and global execution context. If not specified, or ``None``, an empty dictionary is used. If specified, a shallow copy of the dictionary is used.
The :class:`DebugRunner` class, and the special exceptions it may raise, are of
most interest to testing framework authors, and will only be sketched here. See
the sour... | trusted_official_docs | CPython Docs | local and global execution context. If not specified, or ``None``, an empty dictionary is used. If specified, a shallow copy of the dictionary is used.
The :class:`DebugRunner` class, and the special exceptions it may raise, are of
most interest to testing framework authors, and will only be sketched here. See
the sour... | local and global execution context. If not specified, or ``None``, an empty dictionary is used. If specified, a shallow copy of the dictionary is used.
The :class:`DebugRunner` class, and the special exceptions it may raise, are of
most interest to testing framework authors, and will only be sketched here. See
the sour... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e2aad035-8d2d-4b03-8224-c4ba63a81bc9 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,633 | supabase-export-v2 | 26a78d0ceaad1bf1 | the least error prone way of handling them. It is possible to use a different algorithm for handling tabs by writing a custom :class:`DocTestParser` class.
* Output to stdout is captured, but not output to stderr (exception tracebacks
are captured via a different means). | trusted_official_docs | CPython Docs | the least error prone way of handling them. It is possible to use a different algorithm for handling tabs by writing a custom :class:`DocTestParser` class.
* Output to stdout is captured, but not output to stderr (exception tracebacks
are captured via a different means). | the least error prone way of handling them. It is possible to use a different algorithm for handling tabs by writing a custom :class:`DocTestParser` class.
* Output to stdout is captured, but not output to stderr (exception tracebacks
are captured via a different means). | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e324d09a-7199-4257-88d0-748d02314981 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,982 | supabase-export-v2 | 734caf6e015d2e70 | the object's docstring converted to a Python script, as described for :func:`script_from_examples` above. For example, if module :file:`a.py` contains a top-level function :func:`!f`, then ::
import a, doctest
print(doctest.testsource(a, "a.f")) | trusted_official_docs | CPython Docs | the object's docstring converted to a Python script, as described for :func:`script_from_examples` above. For example, if module :file:`a.py` contains a top-level function :func:`!f`, then ::
import a, doctest
print(doctest.testsource(a, "a.f")) | the object's docstring converted to a Python script, as described for :func:`script_from_examples` above. For example, if module :file:`a.py` contains a top-level function :func:`!f`, then ::
import a, doctest
print(doctest.testsource(a, "a.f")) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e42d8ce5-f7fb-4cda-932a-a42cdd2cab92 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,751 | supabase-export-v2 | f980faccbca5098c | >>> 1000**0.1 # risky 1.9952623149688797 >>> round(1000**0.1, 9) # safer 1.995262315 >>> print(f'{1000**0.1:.4f}') # much safer 1.9953
Numbers of the form ``I/2.**J`` are safe across all platforms, and I often
contrive doctest examples to produce numbers of that form:: | trusted_official_docs | CPython Docs | >>> 1000**0.1 # risky 1.9952623149688797 >>> round(1000**0.1, 9) # safer 1.995262315 >>> print(f'{1000**0.1:.4f}') # much safer 1.9953
Numbers of the form ``I/2.**J`` are safe across all platforms, and I often
contrive doctest examples to produce numbers of that form:: | >>> 1000**0.1 # risky 1.9952623149688797 >>> round(1000**0.1, 9) # safer 1.995262315 >>> print(f'{1000**0.1:.4f}') # much safer 1.9953
Numbers of the form ``I/2.**J`` are safe across all platforms, and I often
contrive doctest examples to produce numbers of that form:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e4784137-21b8-455d-9579-979cec9e4a49 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,653 | supabase-export-v2 | f7d0f3fa4fb4e105 | Traceback (most recent call last): Traceback (innermost last):
The traceback header is followed by an optional traceback stack, whose contents
are ignored by doctest. The traceback stack is typically omitted, or copied
verbatim from an interactive session. | trusted_official_docs | CPython Docs | Traceback (most recent call last): Traceback (innermost last):
The traceback header is followed by an optional traceback stack, whose contents
are ignored by doctest. The traceback stack is typically omitted, or copied
verbatim from an interactive session. | Traceback (most recent call last): Traceback (innermost last):
The traceback header is followed by an optional traceback stack, whose contents
are ignored by doctest. The traceback stack is typically omitted, or copied
verbatim from an interactive session. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e579ea96-7120-41d7-b4fe-f1431e6d95c2 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,804 | supabase-export-v2 | 861027d497a0fab3 | The *setUp* function will be passed a :class:`DocTest` object. The *setUp* function can access the test globals as the :attr:`~DocTest.globs` attribute of the test passed.
Optional argument *tearDown* specifies a tear-down function for the test
suite. This is called after running the tests in each file. The *tearDown*... | trusted_official_docs | CPython Docs | The *setUp* function will be passed a :class:`DocTest` object. The *setUp* function can access the test globals as the :attr:`~DocTest.globs` attribute of the test passed.
Optional argument *tearDown* specifies a tear-down function for the test
suite. This is called after running the tests in each file. The *tearDown*... | The *setUp* function will be passed a :class:`DocTest` object. The *setUp* function can access the test globals as the :attr:`~DocTest.globs` attribute of the test passed.
Optional argument *tearDown* specifies a tear-down function for the test
suite. This is called after running the tests in each file. The *tearDown*... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e58419ac-c31a-472c-904f-c27f6a8e5a09 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,651 | supabase-export-v2 | d062f9b8bf453899 | That doctest succeeds if :exc:`ValueError` is raised, with the ``list.remove(x): x not in list`` detail as shown.
The expected output for an exception must start with a traceback header, which
may be either of the following two lines, indented the same as the first line of
the example:: | trusted_official_docs | CPython Docs | That doctest succeeds if :exc:`ValueError` is raised, with the ``list.remove(x): x not in list`` detail as shown.
The expected output for an exception must start with a traceback header, which
may be either of the following two lines, indented the same as the first line of
the example:: | That doctest succeeds if :exc:`ValueError` is raised, with the ``list.remove(x): x not in list`` detail as shown.
The expected output for an exception must start with a traceback header, which
may be either of the following two lines, indented the same as the first line of
the example:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e6253f5c-b6e8-4bcf-8f4f-85a94d7b7bde | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,537 | supabase-export-v2 | 97ad27cd70409417 | illustrated with input-output examples. Depending on whether the examples or the expository text are emphasized, this has the flavor of "literate testing" or "executable documentation".
Here's a complete but small example module:: | trusted_official_docs | CPython Docs | illustrated with input-output examples. Depending on whether the examples or the expository text are emphasized, this has the flavor of "literate testing" or "executable documentation".
Here's a complete but small example module:: | illustrated with input-output examples. Depending on whether the examples or the expository text are emphasized, this has the flavor of "literate testing" or "executable documentation".
Here's a complete but small example module:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e9544f3e-fd89-47cd-9df3-7c4da4deab9e | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,783 | supabase-export-v2 | 523317194f848a25 | Test examples associated with object *f*; for example, *f* may be a string, a module, a function, or a class object.
A shallow copy of dictionary argument *globs* is used for the execution context. | trusted_official_docs | CPython Docs | Test examples associated with object *f*; for example, *f* may be a string, a module, a function, or a class object.
A shallow copy of dictionary argument *globs* is used for the execution context. | Test examples associated with object *f*; for example, *f* may be a string, a module, a function, or a class object.
A shallow copy of dictionary argument *globs* is used for the execution context. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e9bb1dd5-b0b7-499b-89a7-af80d7997b9c | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,629 | supabase-export-v2 | ec98ca56b9707dc0 | .. index:: single: >>>; interpreter prompt single: ...; interpreter prompt
Any expected output must immediately follow the final ``'>>> '`` or ``'... '``
line containing the code, and the expected output (if any) extends to the next
``'>>> '`` or all-whitespace line. | trusted_official_docs | CPython Docs | .. index:: single: >>>; interpreter prompt single: ...; interpreter prompt
Any expected output must immediately follow the final ``'>>> '`` or ``'... '``
line containing the code, and the expected output (if any) extends to the next
``'>>> '`` or all-whitespace line. | .. index:: single: >>>; interpreter prompt single: ...; interpreter prompt
Any expected output must immediately follow the final ``'>>> '`` or ``'... '``
line containing the code, and the expected output (if any) extends to the next
``'>>> '`` or all-whitespace line. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ea4e27f0-f409-4efa-93d1-c7235ed2378f | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,840 | supabase-export-v2 | a0b48b99df3cde1b | * :class:`DocTestParser`: Creates a :class:`DocTest` object from a string (such as an object's docstring).
* :class:`DocTestRunner`: Executes the examples in a :class:`DocTest`, and uses
an :class:`OutputChecker` to verify their output. | trusted_official_docs | CPython Docs | * :class:`DocTestParser`: Creates a :class:`DocTest` object from a string (such as an object's docstring).
* :class:`DocTestRunner`: Executes the examples in a :class:`DocTest`, and uses
an :class:`OutputChecker` to verify their output. | * :class:`DocTestParser`: Creates a :class:`DocTest` object from a string (such as an object's docstring).
* :class:`DocTestRunner`: Executes the examples in a :class:`DocTest`, and uses
an :class:`OutputChecker` to verify their output. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
eae23480-770a-4566-941d-1bb7e1dc492a | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,560 | supabase-export-v2 | 037181c49441f3c5 | Simple Usage: Checking Examples in Docstrings ---------------------------------------------
The simplest way to start using doctest (but not necessarily the way you'll
continue to do it) is to end each module :mod:`!M` with:: | trusted_official_docs | CPython Docs | Simple Usage: Checking Examples in Docstrings ---------------------------------------------
The simplest way to start using doctest (but not necessarily the way you'll
continue to do it) is to end each module :mod:`!M` with:: | Simple Usage: Checking Examples in Docstrings ---------------------------------------------
The simplest way to start using doctest (but not necessarily the way you'll
continue to do it) is to end each module :mod:`!M` with:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
eb222128-85dc-4c87-a2ef-f4e8aa71695e | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,555 | supabase-export-v2 | 31a03f39d2ba2dc3 | .. code-block:: none
Trying:
factorial(1e100)
Expecting:
Traceback (most recent call last):
... OverflowError: n too large
ok
2 items passed all tests:
1 test in __main__
6 tests in __main__.factorial
7 tests in 2 items. 7 passed. Test passed. $ | trusted_official_docs | CPython Docs | .. code-block:: none
Trying:
factorial(1e100)
Expecting:
Traceback (most recent call last):
... OverflowError: n too large
ok
2 items passed all tests:
1 test in __main__
6 tests in __main__.factorial
7 tests in 2 items. 7 passed. Test passed. $ | .. code-block:: none
Trying:
factorial(1e100)
Expecting:
Traceback (most recent call last):
... OverflowError: n too large
ok
2 items passed all tests:
1 test in __main__
6 tests in __main__.factorial
7 tests in 2 items. 7 passed. Test passed. $ | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
eb28e357-b82b-4a16-a852-cd2593092279 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,931 | supabase-export-v2 | 3a47e6ecf27b9697 | .. method:: report_success(out, test, example, got)
Report that the given example ran successfully. This method is provided to
allow subclasses of :class:`DocTestRunner` to customize their output; it
should not be called directly. | trusted_official_docs | CPython Docs | .. method:: report_success(out, test, example, got)
Report that the given example ran successfully. This method is provided to
allow subclasses of :class:`DocTestRunner` to customize their output; it
should not be called directly. | .. method:: report_success(out, test, example, got)
Report that the given example ran successfully. This method is provided to
allow subclasses of :class:`DocTestRunner` to customize their output; it
should not be called directly. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ed128ccd-0178-4a19-8c21-293475ce9538 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,970 | supabase-export-v2 | 69d37d7f9c18e819 | list 1 def f(x): 2 -> g(x*2) [EOF] (Pdb) p x 3 (Pdb) step --Return-- > <doctest a[2]>(1)?()->None -> f(3) (Pdb) cont (0, 3) >>>
Functions that convert doctests to Python code, and possibly run the synthesized
code under the debugger: | trusted_official_docs | CPython Docs | list 1 def f(x): 2 -> g(x*2) [EOF] (Pdb) p x 3 (Pdb) step --Return-- > <doctest a[2]>(1)?()->None -> f(3) (Pdb) cont (0, 3) >>>
Functions that convert doctests to Python code, and possibly run the synthesized
code under the debugger: | list 1 def f(x): 2 -> g(x*2) [EOF] (Pdb) p x 3 (Pdb) step --Return-- > <doctest a[2]>(1)?()->None -> f(3) (Pdb) cont (0, 3) >>>
Functions that convert doctests to Python code, and possibly run the synthesized
code under the debugger: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ed280896-4ca9-48e1-9da2-e77ebfe0e33c | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,904 | supabase-export-v2 | dcef24fe299a4077 | Extract all doctest examples from the given string, and collect them into a :class:`DocTest` object.
*globs*, *name*, *filename*, and *lineno* are attributes for the new
:class:`!DocTest` object. See the documentation for :class:`DocTest` for more
information. | trusted_official_docs | CPython Docs | Extract all doctest examples from the given string, and collect them into a :class:`DocTest` object.
*globs*, *name*, *filename*, and *lineno* are attributes for the new
:class:`!DocTest` object. See the documentation for :class:`DocTest` for more
information. | Extract all doctest examples from the given string, and collect them into a :class:`DocTest` object.
*globs*, *name*, *filename*, and *lineno* are attributes for the new
:class:`!DocTest` object. See the documentation for :class:`DocTest` for more
information. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
edcab592-129e-42f8-b737-a1878db07e56 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,561 | supabase-export-v2 | 763034d3a727d1e2 | The simplest way to start using doctest (but not necessarily the way you'll continue to do it) is to end each module :mod:`!M` with::
if __name__ == "__main__":
import doctest
doctest.testmod() | trusted_official_docs | CPython Docs | The simplest way to start using doctest (but not necessarily the way you'll continue to do it) is to end each module :mod:`!M` with::
if __name__ == "__main__":
import doctest
doctest.testmod() | The simplest way to start using doctest (but not necessarily the way you'll continue to do it) is to end each module :mod:`!M` with::
if __name__ == "__main__":
import doctest
doctest.testmod() | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
edeafe9d-95d2-4f0b-b9c2-36d870b91608 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,934 | supabase-export-v2 | 3b0f7c800aa471a3 | .. method:: report_failure(out, test, example, got)
Report that the given example failed. This method is provided to allow
subclasses of :class:`DocTestRunner` to customize their output; it should not
be called directly. | trusted_official_docs | CPython Docs | .. method:: report_failure(out, test, example, got)
Report that the given example failed. This method is provided to allow
subclasses of :class:`DocTestRunner` to customize their output; it should not
be called directly. | .. method:: report_failure(out, test, example, got)
Report that the given example failed. This method is provided to allow
subclasses of :class:`DocTestRunner` to customize their output; it should not
be called directly. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
eff17506-5353-40bc-9def-1d50c2bc3d33 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,785 | supabase-export-v2 | bdbc56b06bef68f4 | Optional argument *name* is used in failure messages, and defaults to ``"NoName"``.
If optional argument *verbose* is true, output is generated even if there are no
failures. By default, output is generated only in case of an example failure. | trusted_official_docs | CPython Docs | Optional argument *name* is used in failure messages, and defaults to ``"NoName"``.
If optional argument *verbose* is true, output is generated even if there are no
failures. By default, output is generated only in case of an example failure. | Optional argument *name* is used in failure messages, and defaults to ``"NoName"``.
If optional argument *verbose* is true, output is generated even if there are no
failures. By default, output is generated only in case of an example failure. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f19658d9-d0f0-4714-b30e-f4344f42bf70 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,843 | supabase-export-v2 | 14011ee2892a869f | The relationships among these processing classes are summarized in the following diagram::
list of:
+------+ +---------+
|module| --DocTestFinder-> | DocTest | --DocTestRunner-> results
+------+ | ^ +---------+ | ^ (printed)
| | | Example | | |
v | | ... | v |
DocTestParser | Example | OutputChecker
+---------+ | trusted_official_docs | CPython Docs | The relationships among these processing classes are summarized in the following diagram::
list of:
+------+ +---------+
|module| --DocTestFinder-> | DocTest | --DocTestRunner-> results
+------+ | ^ +---------+ | ^ (printed)
| | | Example | | |
v | | ... | v |
DocTestParser | Example | OutputChecker
+---------+ | The relationships among these processing classes are summarized in the following diagram::
list of:
+------+ +---------+
|module| --DocTestFinder-> | DocTest | --DocTestRunner-> results
+------+ | ^ +---------+ | ^ (printed)
| | | Example | | |
v | | ... | v |
DocTestParser | Example | OutputChecker
+---------+ | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f2d3a223-7395-4bc5-be48-d38af28c3567 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,791 | supabase-export-v2 | 82272fed4c450984 | :mod:`unittest` test suites from modules and text files containing doctests. To integrate with :mod:`unittest` test discovery, include a :ref:`load_tests <load_tests-protocol>` function in your test module::
import unittest
import doctest
import my_module_with_doctests | trusted_official_docs | CPython Docs | :mod:`unittest` test suites from modules and text files containing doctests. To integrate with :mod:`unittest` test discovery, include a :ref:`load_tests <load_tests-protocol>` function in your test module::
import unittest
import doctest
import my_module_with_doctests | :mod:`unittest` test suites from modules and text files containing doctests. To integrate with :mod:`unittest` test discovery, include a :ref:`load_tests <load_tests-protocol>` function in your test module::
import unittest
import doctest
import my_module_with_doctests | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f2e0c0f2-b467-4492-bc57-d4f627052f06 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 32,000 | supabase-export-v2 | 612210982a9d4e3b | .. exception:: DocTestFailure(test, example, got)
An exception raised by :class:`DocTestRunner` to signal that a doctest example's
actual output did not match its expected output. The constructor arguments are
used to initialize the attributes of the same names. | trusted_official_docs | CPython Docs | .. exception:: DocTestFailure(test, example, got)
An exception raised by :class:`DocTestRunner` to signal that a doctest example's
actual output did not match its expected output. The constructor arguments are
used to initialize the attributes of the same names. | .. exception:: DocTestFailure(test, example, got)
An exception raised by :class:`DocTestRunner` to signal that a doctest example's
actual output did not match its expected output. The constructor arguments are
used to initialize the attributes of the same names. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f3db4e9a-510e-4ced-8bf3-11329cc890f1 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,922 | supabase-export-v2 | f31377eeea01e683 | of attempted, failed and skipped examples is also available via the :attr:`tries`, :attr:`failures` and :attr:`skips` attributes. The :meth:`run` and :meth:`summarize` methods return a :class:`TestResults` instance.
:class:`DocTestRunner` defines the following methods: | trusted_official_docs | CPython Docs | of attempted, failed and skipped examples is also available via the :attr:`tries`, :attr:`failures` and :attr:`skips` attributes. The :meth:`run` and :meth:`summarize` methods return a :class:`TestResults` instance.
:class:`DocTestRunner` defines the following methods: | of attempted, failed and skipped examples is also available via the :attr:`tries`, :attr:`failures` and :attr:`skips` attributes. The :meth:`run` and :meth:`summarize` methods return a :class:`TestResults` instance.
:class:`DocTestRunner` defines the following methods: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f63fe210-abe2-4d59-959f-18354d7f8c92 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,965 | supabase-export-v2 | 451da3b684a90c27 | raises an exception for the first failing example, containing information about that example. This information can be used to perform post-mortem debugging on the example.
* The :mod:`unittest` cases generated by :func:`DocTestSuite` support the
:meth:`debug` method defined by :class:`unittest.TestCase`. | trusted_official_docs | CPython Docs | raises an exception for the first failing example, containing information about that example. This information can be used to perform post-mortem debugging on the example.
* The :mod:`unittest` cases generated by :func:`DocTestSuite` support the
:meth:`debug` method defined by :class:`unittest.TestCase`. | raises an exception for the first failing example, containing information about that example. This information can be used to perform post-mortem debugging on the example.
* The :mod:`unittest` cases generated by :func:`DocTestSuite` support the
:meth:`debug` method defined by :class:`unittest.TestCase`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fa01a106-7440-4d18-b07d-5b77803ed06d | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,569 | supabase-export-v2 | 2578fcee1f253305 | and a detailed report of all examples tried is printed to standard output, along with assorted summaries at the end.
You can force verbose mode by passing ``verbose=True`` to :func:`testmod`, or
prohibit it by passing ``verbose=False``. In either of those cases,
:data:`sys.argv` is not examined by :func:`testmod` (so p... | trusted_official_docs | CPython Docs | and a detailed report of all examples tried is printed to standard output, along with assorted summaries at the end.
You can force verbose mode by passing ``verbose=True`` to :func:`testmod`, or
prohibit it by passing ``verbose=False``. In either of those cases,
:data:`sys.argv` is not examined by :func:`testmod` (so p... | and a detailed report of all examples tried is printed to standard output, along with assorted summaries at the end.
You can force verbose mode by passing ``verbose=True`` to :func:`testmod`, or
prohibit it by passing ``verbose=False``. In either of those cases,
:data:`sys.argv` is not examined by :func:`testmod` (so p... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fad5a38f-9719-4304-b609-12bb3dd5322e | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,533 | supabase-export-v2 | c49e46f8d0762af3 | --------------
The :mod:`!doctest` module searches for pieces of text that look like interactive
Python sessions, and then executes those sessions to verify that they work
exactly as shown. There are several common ways to use doctest: | trusted_official_docs | CPython Docs | --------------
The :mod:`!doctest` module searches for pieces of text that look like interactive
Python sessions, and then executes those sessions to verify that they work
exactly as shown. There are several common ways to use doctest: | --------------
The :mod:`!doctest` module searches for pieces of text that look like interactive
Python sessions, and then executes those sessions to verify that they work
exactly as shown. There are several common ways to use doctest: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fadb8cc2-bcf5-4a30-83a5-e653881703c4 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,943 | supabase-export-v2 | e38d693195a3baf1 | by the Python compiler when running the examples. If not specified, then it will default to the set of future-import flags that apply to *globs*.
The output of each example is checked using the :class:`DocTestRunner`'s
output checker, and the results are formatted by the
:meth:`!DocTestRunner.report_\*` methods. | trusted_official_docs | CPython Docs | by the Python compiler when running the examples. If not specified, then it will default to the set of future-import flags that apply to *globs*.
The output of each example is checked using the :class:`DocTestRunner`'s
output checker, and the results are formatted by the
:meth:`!DocTestRunner.report_\*` methods. | by the Python compiler when running the examples. If not specified, then it will default to the set of future-import flags that apply to *globs*.
The output of each example is checked using the :class:`DocTestRunner`'s
output checker, and the results are formatted by the
:meth:`!DocTestRunner.report_\*` methods. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fbf278d3-938a-4799-b2e9-4f28dbf55ba5 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,680 | supabase-export-v2 | b93c8aaabf620519 | :const:`NORMALIZE_WHITESPACE` is especially useful when a line of expected output is very long, and you want to wrap it across multiple lines in your source.
.. index:: single: ...; in doctests
.. data:: ELLIPSIS | trusted_official_docs | CPython Docs | :const:`NORMALIZE_WHITESPACE` is especially useful when a line of expected output is very long, and you want to wrap it across multiple lines in your source.
.. index:: single: ...; in doctests
.. data:: ELLIPSIS | :const:`NORMALIZE_WHITESPACE` is especially useful when a line of expected output is very long, and you want to wrap it across multiple lines in your source.
.. index:: single: ...; in doctests
.. data:: ELLIPSIS | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fcfeb35d-2370-4420-90ca-58bd6a9d1aa3 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,718 | supabase-export-v2 | e18f8d22cf556186 | allowed between the ``+`` or ``-`` and the directive option name. The directive option name can be any of the option flag names explained above.
An example's doctest directives modify doctest's behavior for that single
example. Use ``+`` to enable the named behavior, or ``-`` to disable it. | trusted_official_docs | CPython Docs | allowed between the ``+`` or ``-`` and the directive option name. The directive option name can be any of the option flag names explained above.
An example's doctest directives modify doctest's behavior for that single
example. Use ``+`` to enable the named behavior, or ``-`` to disable it. | allowed between the ``+`` or ``-`` and the directive option name. The directive option name can be any of the option flag names explained above.
An example's doctest directives modify doctest's behavior for that single
example. Use ``+`` to enable the named behavior, or ``-`` to disable it. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fdad925d-d233-4d93-be83-d53b8d0bd561 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,706 | supabase-export-v2 | bbf0f8c9b1a5ba47 | .. data:: FAIL_FAST
When specified, exit after the first failing example and don't attempt to run
the remaining examples. Thus, the number of failures reported will be at most
1. This flag may be useful during debugging, since examples after the first
failure won't even produce debugging output. | trusted_official_docs | CPython Docs | .. data:: FAIL_FAST
When specified, exit after the first failing example and don't attempt to run
the remaining examples. Thus, the number of failures reported will be at most
1. This flag may be useful during debugging, since examples after the first
failure won't even produce debugging output. | .. data:: FAIL_FAST
When specified, exit after the first failing example and don't attempt to run
the remaining examples. Thus, the number of failures reported will be at most
1. This flag may be useful during debugging, since examples after the first
failure won't even produce debugging output. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fe547797-7e6d-4f3a-9e4c-29ab1af69439 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,988 | supabase-export-v2 | 839392594807d06c | A shallow copy of ``module.__dict__`` is used for both local and global execution context.
Optional argument *pm* controls whether post-mortem debugging is used. If *pm*
has a true value, the script file is run directly, and the debugger gets
involved only if the script terminates via raising an unhandled exception. ... | trusted_official_docs | CPython Docs | A shallow copy of ``module.__dict__`` is used for both local and global execution context.
Optional argument *pm* controls whether post-mortem debugging is used. If *pm*
has a true value, the script file is run directly, and the debugger gets
involved only if the script terminates via raising an unhandled exception. ... | A shallow copy of ``module.__dict__`` is used for both local and global execution context.
Optional argument *pm* controls whether post-mortem debugging is used. If *pm*
has a true value, the script file is run directly, and the debugger gets
involved only if the script terminates via raising an unhandled exception. ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fef6069e-4abb-4bfa-b1af-072a6e2326bc | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,930 | supabase-export-v2 | b464f2ae46a771f3 | *example* is the example about to be processed. *test* is the test containing *example*. *out* is the output function that was passed to :meth:`DocTestRunner.run`.
.. method:: report_success(out, test, example, got) | trusted_official_docs | CPython Docs | *example* is the example about to be processed. *test* is the test containing *example*. *out* is the output function that was passed to :meth:`DocTestRunner.run`.
.. method:: report_success(out, test, example, got) | *example* is the example about to be processed. *test* is the test containing *example*. *out* is the output function that was passed to :meth:`DocTestRunner.run`.
.. method:: report_success(out, test, example, got) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0bd37b07-8b85-48bc-8748-a80bb9fded79 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,100 | supabase-export-v2 | cb26d1e27b4706b4 | ')' 2,26-2,27: NEWLINE '\n' 3,0-3,1: NL '\n' 4,0-4,0: DEDENT '' 4,0-4,9: NAME 'say_hello' 4,9-4,10: OP '(' 4,10-4,11: OP ')' 4,11-4,12: NEWLINE '\n' 5,0-5,0: ENDMARKER ''
The exact token type names can be displayed using the :option:`-e` option: | trusted_official_docs | CPython Docs | ')' 2,26-2,27: NEWLINE '\n' 3,0-3,1: NL '\n' 4,0-4,0: DEDENT '' 4,0-4,9: NAME 'say_hello' 4,9-4,10: OP '(' 4,10-4,11: OP ')' 4,11-4,12: NEWLINE '\n' 5,0-5,0: ENDMARKER ''
The exact token type names can be displayed using the :option:`-e` option: | ')' 2,26-2,27: NEWLINE '\n' 3,0-3,1: NL '\n' 4,0-4,0: DEDENT '' 4,0-4,9: NAME 'say_hello' 4,9-4,10: OP '(' 4,10-4,11: OP ')' 4,11-4,12: NEWLINE '\n' 5,0-5,0: ENDMARKER ''
The exact token type names can be displayed using the :option:`-e` option: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0dd50f5f-dbdd-4651-a8e0-09b5ce84ad21 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,045 | supabase-export-v2 | e576c4ac399b8371 | .. function:: tokenize(readline)
The :func:`.tokenize` generator requires one argument, *readline*, which
must be a callable object which provides the same interface as the
:meth:`io.IOBase.readline` method of file objects. Each call to the
function should return one line of input as bytes. | trusted_official_docs | CPython Docs | .. function:: tokenize(readline)
The :func:`.tokenize` generator requires one argument, *readline*, which
must be a callable object which provides the same interface as the
:meth:`io.IOBase.readline` method of file objects. Each call to the
function should return one line of input as bytes. | .. function:: tokenize(readline)
The :func:`.tokenize` generator requires one argument, *readline*, which
must be a callable object which provides the same interface as the
:meth:`io.IOBase.readline` method of file objects. Each call to the
function should return one line of input as bytes. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1019d111-f3d2-44b7-aa8d-e67cd346cff9 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,038 | supabase-export-v2 | a3873d6439bccd0a | --------------
The :mod:`!tokenize` module provides a lexical scanner for Python source code,
implemented in Python. The scanner in this module returns comments as tokens
as well, making it useful for implementing "pretty-printers", including
colorizers for on-screen displays. | trusted_official_docs | CPython Docs | --------------
The :mod:`!tokenize` module provides a lexical scanner for Python source code,
implemented in Python. The scanner in this module returns comments as tokens
as well, making it useful for implementing "pretty-printers", including
colorizers for on-screen displays. | --------------
The :mod:`!tokenize` module provides a lexical scanner for Python source code,
implemented in Python. The scanner in this module returns comments as tokens
as well, making it useful for implementing "pretty-printers", including
colorizers for on-screen displays. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
19baff1e-ee3b-4dbe-9644-6f9a66bab786 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,093 | supabase-export-v2 | 120f3f03d81e5a44 | Output from calculations with Decimal should be identical across all platforms.
>>> exec(decistmt(s))
-3.217160342717258261933904529E-7
"""
result = []
g = tokenize(BytesIO(s.encode('utf-8')).readline) # tokenize the string
for toknum, tokval, _, _, _ in g:
if toknum == NUMBER and '.' in tokval: # replace NUMBER ... | trusted_official_docs | CPython Docs | Output from calculations with Decimal should be identical across all platforms.
>>> exec(decistmt(s))
-3.217160342717258261933904529E-7
"""
result = []
g = tokenize(BytesIO(s.encode('utf-8')).readline) # tokenize the string
for toknum, tokval, _, _, _ in g:
if toknum == NUMBER and '.' in tokval: # replace NUMBER ... | Output from calculations with Decimal should be identical across all platforms.
>>> exec(decistmt(s))
-3.217160342717258261933904529E-7
"""
result = []
g = tokenize(BytesIO(s.encode('utf-8')).readline) # tokenize the string
for toknum, tokval, _, _, _ in g:
if toknum == NUMBER and '.' in tokval: # replace NUMBER ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
24d94082-2aeb-4e80-82ae-350457764591 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,058 | supabase-export-v2 | d2ec99fb7009ed7d | .. function:: untokenize(iterable)
Converts tokens back into Python source code. The *iterable* must return
sequences with at least two elements, the token type and the token string. Any additional sequence elements are ignored. | trusted_official_docs | CPython Docs | .. function:: untokenize(iterable)
Converts tokens back into Python source code. The *iterable* must return
sequences with at least two elements, the token type and the token string. Any additional sequence elements are ignored. | .. function:: untokenize(iterable)
Converts tokens back into Python source code. The *iterable* must return
sequences with at least two elements, the token type and the token string. Any additional sequence elements are ignored. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
36bd36ac-1741-42a6-98df-c6e514b3457d | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,054 | supabase-export-v2 | 9c2d19747a149899 | :func:`.tokenize`, the *readline* argument is a callable returning a single line of input. However, :func:`generate_tokens` expects *readline* to return a str object rather than bytes.
The result is an iterator yielding named tuples, exactly like
:func:`.tokenize`. It does not yield an :data:`~token.ENCODING` token. | trusted_official_docs | CPython Docs | :func:`.tokenize`, the *readline* argument is a callable returning a single line of input. However, :func:`generate_tokens` expects *readline* to return a str object rather than bytes.
The result is an iterator yielding named tuples, exactly like
:func:`.tokenize`. It does not yield an :data:`~token.ENCODING` token. | :func:`.tokenize`, the *readline* argument is a callable returning a single line of input. However, :func:`generate_tokens` expects *readline* to return a str object rather than bytes.
The result is an iterator yielding named tuples, exactly like
:func:`.tokenize`. It does not yield an :data:`~token.ENCODING` token. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3cde3e6b-88a9-47c1-900b-2c044b0eef6a | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,053 | supabase-export-v2 | 43733879d057df4f | Tokenize a source reading unicode strings instead of bytes.
Like :func:`.tokenize`, the *readline* argument is a callable returning
a single line of input. However, :func:`generate_tokens` expects *readline*
to return a str object rather than bytes. | trusted_official_docs | CPython Docs | Tokenize a source reading unicode strings instead of bytes.
Like :func:`.tokenize`, the *readline* argument is a callable returning
a single line of input. However, :func:`generate_tokens` expects *readline*
to return a str object rather than bytes. | Tokenize a source reading unicode strings instead of bytes.
Like :func:`.tokenize`, the *readline* argument is a callable returning
a single line of input. However, :func:`generate_tokens` expects *readline*
to return a str object rather than bytes. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
50449413-5ae0-41e8-af5b-512631577837 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,064 | supabase-export-v2 | 93065e906be68713 | the encoding that should be used to decode a Python source file. It requires one argument, readline, in the same way as the :func:`.tokenize` generator.
It will call readline a maximum of twice, and return the encoding used
(as a string) and a list of any lines (not decoded from bytes) it has read
in. | trusted_official_docs | CPython Docs | the encoding that should be used to decode a Python source file. It requires one argument, readline, in the same way as the :func:`.tokenize` generator.
It will call readline a maximum of twice, and return the encoding used
(as a string) and a list of any lines (not decoded from bytes) it has read
in. | the encoding that should be used to decode a Python source file. It requires one argument, readline, in the same way as the :func:`.tokenize` generator.
It will call readline a maximum of twice, and return the encoding used
(as a string) and a list of any lines (not decoded from bytes) it has read
in. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5308ed86-b3dd-4a04-8fd6-f9b5b54ee500 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,094 | supabase-export-v2 | aa235909f2d60bd7 | == NUMBER and '.' in tokval: # replace NUMBER tokens result.extend([ (NAME, 'Decimal'), (OP, '('), (STRING, repr(tokval)), (OP, ')') ]) else: result.append((toknum, tokval)) return untokenize(result).decode('utf-8')
Example of tokenizing from the command line. The script:: | trusted_official_docs | CPython Docs | == NUMBER and '.' in tokval: # replace NUMBER tokens result.extend([ (NAME, 'Decimal'), (OP, '('), (STRING, repr(tokval)), (OP, ')') ]) else: result.append((toknum, tokval)) return untokenize(result).decode('utf-8')
Example of tokenizing from the command line. The script:: | == NUMBER and '.' in tokval: # replace NUMBER tokens result.extend([ (NAME, 'Decimal'), (OP, '('), (STRING, repr(tokval)), (OP, ')') ]) else: result.append((toknum, tokval)) return untokenize(result).decode('utf-8')
Example of tokenizing from the command line. The script:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
55f31b43-928d-4671-a377-2721eb7c0e88 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,061 | supabase-export-v2 | 96cc188113609cc9 | :data:`~token.ENCODING` token, which is the first token sequence output by :func:`.tokenize`. If there is no encoding token in the input, it returns a str instead.
:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The
function it uses to do this is available: | trusted_official_docs | CPython Docs | :data:`~token.ENCODING` token, which is the first token sequence output by :func:`.tokenize`. If there is no encoding token in the input, it returns a str instead.
:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The
function it uses to do this is available: | :data:`~token.ENCODING` token, which is the first token sequence output by :func:`.tokenize`. If there is no encoding token in the input, it returns a str instead.
:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The
function it uses to do this is available: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7a334254-3ae5-4705-ac00-c057c91e651d | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,091 | supabase-export-v2 | 46b90b2b3b19706f | and "e-07" (not Windows). Since we're only showing 12 digits, and the 13th isn't close to 5, the rest of the output should be platform-independent.
>>> exec(s) #doctest: +ELLIPSIS
-3.21716034272e-0...7 | trusted_official_docs | CPython Docs | and "e-07" (not Windows). Since we're only showing 12 digits, and the 13th isn't close to 5, the rest of the output should be platform-independent.
>>> exec(s) #doctest: +ELLIPSIS
-3.21716034272e-0...7 | and "e-07" (not Windows). Since we're only showing 12 digits, and the 13th isn't close to 5, the rest of the output should be platform-independent.
>>> exec(s) #doctest: +ELLIPSIS
-3.21716034272e-0...7 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8723979b-7654-489c-947b-9827749ddfb0 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,066 | supabase-export-v2 | 4b4428b94e78f651 | a cookie are present, but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found, ``'utf-8-sig'`` will be returned as an encoding.
If no encoding is specified, then the default of ``'utf-8'`` will be
returned. | trusted_official_docs | CPython Docs | a cookie are present, but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found, ``'utf-8-sig'`` will be returned as an encoding.
If no encoding is specified, then the default of ``'utf-8'`` will be
returned. | a cookie are present, but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found, ``'utf-8-sig'`` will be returned as an encoding.
If no encoding is specified, then the default of ``'utf-8'`` will be
returned. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
87fd4103-19cd-454c-97ff-2b805896e2d0 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,102 | supabase-export-v2 | 9c24bd87f8d7b52b | .. code-block:: shell-session
$ python -m tokenize -e hello.py
0,0-0,0: ENCODING 'utf-8'
1,0-1,3: NAME 'def'
1,4-1,13: NAME 'say_hello'
1,13-1,14: LPAR '('
1,14-1,15: RPAR ')'
1,15-1,16: COLON ':'
1,16-1,17: NEWLINE '\n'
2,0-2,4: INDENT ' '
2,4-2,9: NAME 'print'
2,9-2,10: LPAR '('
2,10-2,25: STRING '"Hello, ... | trusted_official_docs | CPython Docs | .. code-block:: shell-session
$ python -m tokenize -e hello.py
0,0-0,0: ENCODING 'utf-8'
1,0-1,3: NAME 'def'
1,4-1,13: NAME 'say_hello'
1,13-1,14: LPAR '('
1,14-1,15: RPAR ')'
1,15-1,16: COLON ':'
1,16-1,17: NEWLINE '\n'
2,0-2,4: INDENT ' '
2,4-2,9: NAME 'print'
2,9-2,10: LPAR '('
2,10-2,25: STRING '"Hello, ... | .. code-block:: shell-session
$ python -m tokenize -e hello.py
0,0-0,0: ENCODING 'utf-8'
1,0-1,3: NAME 'def'
1,4-1,13: NAME 'say_hello'
1,13-1,14: LPAR '('
1,14-1,15: RPAR ')'
1,15-1,16: COLON ':'
1,16-1,17: NEWLINE '\n'
2,0-2,4: INDENT ' '
2,4-2,9: NAME 'print'
2,9-2,10: LPAR '('
2,10-2,25: STRING '"Hello, ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
888fd031-2044-4230-8fc7-6ef59efbfddc | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,103 | supabase-export-v2 | 3ae1e3f767452a0a | ')' 2,26-2,27: NEWLINE '\n' 3,0-3,1: NL '\n' 4,0-4,0: DEDENT '' 4,0-4,9: NAME 'say_hello' 4,9-4,10: LPAR '(' 4,10-4,11: RPAR ')' 4,11-4,12: NEWLINE '\n' 5,0-5,0: ENDMARKER ''
Example of tokenizing a file programmatically, reading unicode
strings instead of bytes with :func:`generate_tokens`:: | trusted_official_docs | CPython Docs | ')' 2,26-2,27: NEWLINE '\n' 3,0-3,1: NL '\n' 4,0-4,0: DEDENT '' 4,0-4,9: NAME 'say_hello' 4,9-4,10: LPAR '(' 4,10-4,11: RPAR ')' 4,11-4,12: NEWLINE '\n' 5,0-5,0: ENDMARKER ''
Example of tokenizing a file programmatically, reading unicode
strings instead of bytes with :func:`generate_tokens`:: | ')' 2,26-2,27: NEWLINE '\n' 3,0-3,1: NL '\n' 4,0-4,0: DEDENT '' 4,0-4,9: NAME 'say_hello' 4,9-4,10: LPAR '(' 4,10-4,11: RPAR ')' 4,11-4,12: NEWLINE '\n' 5,0-5,0: ENDMARKER ''
Example of tokenizing a file programmatically, reading unicode
strings instead of bytes with :func:`generate_tokens`:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8f768ed3-8440-477d-ad4b-2a5a2409bfc3 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,063 | supabase-export-v2 | 157e892f7e238dc4 | .. function:: detect_encoding(readline)
The :func:`detect_encoding` function is used to detect the encoding that
should be used to decode a Python source file. It requires one argument,
readline, in the same way as the :func:`.tokenize` generator. | trusted_official_docs | CPython Docs | .. function:: detect_encoding(readline)
The :func:`detect_encoding` function is used to detect the encoding that
should be used to decode a Python source file. It requires one argument,
readline, in the same way as the :func:`.tokenize` generator. | .. function:: detect_encoding(readline)
The :func:`detect_encoding` function is used to detect the encoding that
should be used to decode a Python source file. It requires one argument,
readline, in the same way as the :func:`.tokenize` generator. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9c4e0187-ef39-426c-84e6-7e226374bb66 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,047 | supabase-export-v2 | dcab9de6953f2d44 | last tuple item) is the *physical* line. The 5 tuple is returned as a :term:`named tuple` with the field names: ``type string start end line``.
The returned :term:`named tuple` has an additional property named
``exact_type`` that contains the exact operator type for
:data:`~token.OP` tokens. For all other token types... | trusted_official_docs | CPython Docs | last tuple item) is the *physical* line. The 5 tuple is returned as a :term:`named tuple` with the field names: ``type string start end line``.
The returned :term:`named tuple` has an additional property named
``exact_type`` that contains the exact operator type for
:data:`~token.OP` tokens. For all other token types... | last tuple item) is the *physical* line. The 5 tuple is returned as a :term:`named tuple` with the field names: ``type string start end line``.
The returned :term:`named tuple` has an additional property named
``exact_type`` that contains the exact operator type for
:data:`~token.OP` tokens. For all other token types... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a7e25531-c387-4ab7-ad87-31862d9066e7 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,056 | supabase-export-v2 | 3e8ec4dd5c9fc597 | All constants from the :mod:`token` module are also exported from :mod:`!tokenize`.
Another function is provided to reverse the tokenization process. This is
useful for creating tools that tokenize a script, modify the token stream, and
write back the modified script. | trusted_official_docs | CPython Docs | All constants from the :mod:`token` module are also exported from :mod:`!tokenize`.
Another function is provided to reverse the tokenization process. This is
useful for creating tools that tokenize a script, modify the token stream, and
write back the modified script. | All constants from the :mod:`token` module are also exported from :mod:`!tokenize`.
Another function is provided to reverse the tokenization process. This is
useful for creating tools that tokenize a script, modify the token stream, and
write back the modified script. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a86da3ec-8129-48a7-8e7b-43a2a5adc7a3 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,099 | supabase-export-v2 | 098f1e358da36620 | .. code-block:: shell-session
$ python -m tokenize hello.py
0,0-0,0: ENCODING 'utf-8'
1,0-1,3: NAME 'def'
1,4-1,13: NAME 'say_hello'
1,13-1,14: OP '('
1,14-1,15: OP ')'
1,15-1,16: OP ':'
1,16-1,17: NEWLINE '\n'
2,0-2,4: INDENT ' '
2,4-2,9: NAME 'print'
2,9-2,10: OP '('
2,10-2,25: STRING '"Hello, World!"'
2,... | trusted_official_docs | CPython Docs | .. code-block:: shell-session
$ python -m tokenize hello.py
0,0-0,0: ENCODING 'utf-8'
1,0-1,3: NAME 'def'
1,4-1,13: NAME 'say_hello'
1,13-1,14: OP '('
1,14-1,15: OP ')'
1,15-1,16: OP ':'
1,16-1,17: NEWLINE '\n'
2,0-2,4: INDENT ' '
2,4-2,9: NAME 'print'
2,9-2,10: OP '('
2,10-2,25: STRING '"Hello, World!"'
2,... | .. code-block:: shell-session
$ python -m tokenize hello.py
0,0-0,0: ENCODING 'utf-8'
1,0-1,3: NAME 'def'
1,4-1,13: NAME 'say_hello'
1,13-1,14: OP '('
1,14-1,15: OP ')'
1,15-1,16: OP ':'
1,16-1,17: NEWLINE '\n'
2,0-2,4: INDENT ' '
2,4-2,9: NAME 'print'
2,9-2,10: OP '('
2,10-2,25: STRING '"Hello, World!"'
2,... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b1c58b45-bef2-4aec-88c8-030482d31707 | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,097 | supabase-export-v2 | 1604d3a479e56adb | say_hello()
will be tokenized to the following output where the first column is the range
of the line/column coordinates where the token is found, the second column is
the name of the token, and the final column is the value of the token (if any): | trusted_official_docs | CPython Docs | say_hello()
will be tokenized to the following output where the first column is the range
of the line/column coordinates where the token is found, the second column is
the name of the token, and the final column is the value of the token (if any): | say_hello()
will be tokenized to the following output where the first column is the range
of the line/column coordinates where the token is found, the second column is
the name of the token, and the final column is the value of the token (if any): | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b4801412-0315-43a9-8884-08685230e78a | CPython Docs | file://datasets/cpython/Doc/library/tokenize.rst | unknown | bcf6704d-8f4c-4f1a-9fea-374d832bdca3 | 32,046 | supabase-export-v2 | c2a64e1c35b1676f | which provides the same interface as the :meth:`io.IOBase.readline` method of file objects. Each call to the function should return one line of input as bytes.
The generator produces 5-tuples with these members: the token type; the
token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and
column where t... | trusted_official_docs | CPython Docs | which provides the same interface as the :meth:`io.IOBase.readline` method of file objects. Each call to the function should return one line of input as bytes.
The generator produces 5-tuples with these members: the token type; the
token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and
column where t... | which provides the same interface as the :meth:`io.IOBase.readline` method of file objects. Each call to the function should return one line of input as bytes.
The generator produces 5-tuples with these members: the token type; the
token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and
column where t... | python, official-docs, cpython, P0 | Local_Trusted_Corpus |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.