summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_doctest.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-93883: elide traceback indicators when possible (#93994)John Belmonte2022-07-111-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gh-93883: elide traceback indicators when possible Elide traceback column indicators when the entire line of the frame is implicated. This reduces traceback length and draws even more attention to the remaining (very relevant) indicators. Example: ``` Traceback (most recent call last): File "query.py", line 99, in <module> bar() File "query.py", line 66, in bar foo() File "query.py", line 37, in foo magic_arithmetic('foo') File "query.py", line 18, in magic_arithmetic return add_counts(x) / 25 ^^^^^^^^^^^^^ File "query.py", line 24, in add_counts return 25 + query_user(user1) + query_user(user2) ^^^^^^^^^^^^^^^^^ File "query.py", line 32, in query_user return 1 + query_count(db, response['a']['b']['c']['user'], retry=True) ~~~~~~~~~~~~~~~~~~^^^^^ TypeError: 'NoneType' object is not subscriptable ``` Rather than going out of our way to provide indicator coverage in every traceback test suite, the indicator test suite should be responible for sufficient coverage (e.g. by adding a basic exception group test to ensure that margin strings are covered).
* gh-84623: Move imports in doctests (#94133)Victor Stinner2022-06-221-3/+3
| | | Move imports in doctests to prevent false alarms in pyflakes.
* bpo-28249: fix `lineno` location for empty `DocTest` instances (GH-30498)Nikita Sobolev2022-05-191-1/+22
| | | | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-2604: Make doctest.DocTestCase reset globs in teardown (GH-31932)Daniël van Noord2022-03-221-0/+16
| | | | | Co-authored-by: Piet Delport Co-authored-by: Hugo Lopes Tavares Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-40280: Skip socket, fork, subprocess tests on Emscripten (GH-31986)Christian Heimes2022-03-221-1/+6
| | | | | | | | | | | - Add requires_fork and requires_subprocess to more tests - Skip extension import tests if dlopen is not available - Don't assume that _testcapi is a shared extension - Skip a lot of socket tests that don't work on Emscripten - Skip mmap tests, mmap emulation is incomplete - venv does not work yet - Cannot get libc from executable The "entire" test suite is now passing on Emscripten with EMSDK from git head (91 suites are skipped).
* bpo-44904: Fix classmethod property bug in doctest module (GH-28838)Alex Waygood2021-10-281-0/+15
| | | | | | | | The doctest module raised an error if a docstring contained an example that attempted to access a classmethod property. (Stacking '@classmethod' on top of `@property` has been supported since Python 3.9; see https://docs.python.org/3/howto/descriptor.html#class-methods.) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-45292: [PEP 654] add the ExceptionGroup and BaseExceptionGroup classes ↵Irit Katriel2021-10-221-1/+1
| | | | (GH-28569)
* bpo-45229: Make doctest tests discoverable (GH-28986)Serhiy Storchaka2021-10-201-14/+6
|
* bpo-24234: implement complex.__complex__ (GH-27887)Mark Dickinson2021-08-231-1/+1
| | | Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* bpo-43950: support some multi-line expressions for PEP 657 (GH-27339)Batuhan Taskaya2021-07-251-0/+1
| | | | | | | | | | | | | | | | | | | | | This is basically something that I noticed up while fixing test runs for another issue. It is really common to have multiline calls, and when they fail the display is kind of weird since we omit the annotations. E.g; ``` $ ./python t.py Traceback (most recent call last): File "/home/isidentical/cpython/cpython/t.py", line 11, in <module> frame_1() ^^^^^^^^^ File "/home/isidentical/cpython/cpython/t.py", line 5, in frame_1 frame_2( File "/home/isidentical/cpython/cpython/t.py", line 2, in frame_2 return a / 0 / b / c ~~^~~ ZeroDivisionError: division by zero ``` This patch basically adds support for annotating the rest of the line, if the instruction covers multiple lines (start_line != end_line). Automerge-Triggered-By: GH:isidentical
* bpo-43950: Add option to opt-out of PEP-657 (GH-27023)Ammar Askar2021-07-071-2/+4
| | | | | Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
* bpo-43950: Print columns in tracebacks (PEP 657) (GH-26958)Ammar Askar2021-07-041-0/+1
| | | | | | | | The traceback.c and traceback.py mechanisms now utilize the newly added code.co_positions and PyCode_Addr2Location to print carets on the specific expressions involved in a traceback. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com> Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
* bpo-35753: Fix crash in doctest with unwrap-able functions (#22981)Alfred Perlstein2021-05-051-1/+14
| | | | | | | | | Ignore objects that inspect.unwrap throws due to too many wrappers. This is a very rare case, however it can easily be surfaced when a module under doctest imports unitest.mock.call into its namespace. We simply skip any object that throws this exception. This should handle the majority of cases.
* bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25142)Inada Naoki2021-04-021-3/+3
| | | | | | | | | | | | | * test__xxsubinterpreters * test_builtin * test_doctest * test_exceptions * test_opcodes * test_support * test_argparse * test_baseexception * test_bdb * test_bool * test_asdl_parser
* bpo-31904: fix test_doctest.py failures for VxWorks (GH-23419)pxinwr2020-12-041-1/+2
| | | | Fix test_doctest.py failures for VxWorks by avoiding exact error message checks. (better for everyone all around)
* bpo-40275: Use new test.support helper submodules in tests (GH-21448)Hai Shi2020-08-031-6/+10
|
* bpo-29882: Add an efficient popcount method for integers (#771)Niklas Fiekas2020-05-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | * bpo-29882: Add an efficient popcount method for integers * Update 'sign bit' and versionadded in docs * Add entry to whatsnew document * Doc: use positive example, mention population count * Minor cleanups of the core code * Move popcount_digit closer to where it's used * Use z instead of self after conversion * Add 'absolute value' and 'population count' to docstring * Fix clinic error about missing summary line * Ensure popcount_digit is portable with 64-bit ints Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-40636: Clarify the zip built-in docstring. (GH-20118)Gregory P. Smith2020-05-151-1/+2
| | | | | | | | | | | | | | | | | | | | | Clarify the zip built-in docstring. This puts much simpler text up front along with an example. As it was, the zip built-in docstring was technically correct. But too technical for the reader who shouldn't _need_ to know about `__next__` and `StopIteration` as most people do not need to understand the internal implementation details of the iterator protocol in their daily life. This is a documentation only change, intended to be backported to 3.8; it is only tangentially related to PEP-618 which might offer new behavior options in the future. Wording based a bit more on enumerate per Brandt's suggestion. This gets rid of the legacy wording paragraph which seems too tied to implementation details of the iterator protocol which isn't relevant here. Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* bpo-39939: Add str.removeprefix and str.removesuffix (GH-18939)sweeneyde2020-04-221-1/+1
| | | | | Added str.removeprefix and str.removesuffix methods and corresponding bytes, bytearray, and collections.UserString methods to remove affixes from a string if present. See PEP 616 for a full description.
* bpo-39481: Implementation for PEP 585 (#18239)Guido van Rossum2020-04-071-1/+1
| | | | | | | | | | | | This implements things like `list[int]`, which returns an object of type `types.GenericAlias`. This object mostly acts as a proxy for `list`, but has attributes `__origin__` and `__args__` that allow recovering the parts (with values `list` and `(int,)`. There is also an approximate notion of type variables; e.g. `list[T]` has a `__parameters__` attribute equal to `(T,)`. Type variables are objects of type `typing.TypeVar`.
* bpo-1812: Fix newline conversion when doctest.testfile loads from a package ↵Peter Donis2020-03-261-4/+89
| | | | | whose loader has a get_data method (GH-17385) This pull request fixes the newline conversion bug originally reported in bpo-1812. When that issue was originally submitted, the open builtin did not default to universal newline mode; now it does, which makes the issue fix simpler, since the only code path that needs to be changed is the one in doctest._load_testfile where the file is loaded from a package whose loader has a get_data method.
* bpo-36406: Handle namespace packages in doctest (GH-12520)Xtreak2019-12-131-1/+5
|
* Fix typos in comments, docs and test names (#15018)Min ho Kim2019-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * Fix typos in comments, docs and test names * Update test_pyparse.py account for change in string length * Apply suggestion: splitable -> splittable Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Apply suggestion: splitable -> splittable Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Apply suggestion: Dealloccte -> Deallocate Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Update posixmodule checksum. * Reverse idlelib changes.
* bpo-22385: Support output separators in hex methods. (#13578)Gregory P. Smith2019-05-291-1/+4
| | | | | | | | | | | | | | | | | | * bpo-22385: Support output separators in hex methods. Also in binascii.hexlify aka b2a_hex. The underlying implementation behind all hex generation in CPython uses the same pystrhex.c implementation. This adds support to bytes, bytearray, and memoryview objects. The binascii module functions exist rather than being slated for deprecation because they return bytes rather than requiring an intermediate step through a str object. This change was inspired by MicroPython which supports sep in its binascii implementation (and does not yet support the .hex methods). https://bugs.python.org/issue22385
* bpo-24746: Fix doctest failures when running the testsuite with -R (#11501)Pablo Galindo2019-01-101-2/+1
|
* bpo-24746: Avoid stripping trailing whitespace in doctest fancy diff (#10639)Sanyam Khurana2019-01-091-1/+47
|
* bpo-12458: Fix line numbers for multiline expressions. (GH-8774)Serhiy Storchaka2018-09-171-1/+1
|
* bpo-33073: Adding as_integer_ratio to ints. (GH-8750)Lisa Roach2018-09-141-1/+2
|
* bpo-33053: -m now adds *starting* directory to sys.path (GH-6231)Nick Coghlan2018-03-251-5/+11
| | | | | | | | | | | | Historically, -m added the empty string as sys.path zero, meaning it resolved imports against the current working directory, the same way -c and the interactive prompt do. This changes the sys.path initialisation to add the *starting* working directory as sys.path[0] instead, such that changes to the working directory while the program is running will have no effect on imports when using the -m switch.
* bpo-32991: Restore expectation that inspect.getfile raises TypeError on ↵Jason R. Coombs2018-03-051-1/+18
| | | | | | | | | | namespace package (GH-5980) * bpo-32991: Add test capturing expectation. DocTestFinder.find should return an empty list for doctests in a namespace package. * bpo-32991: Restore expectation that inspect.getfile on a namespace package raises TypeError.
* bpo-32677: Add .isascii() to str, bytes and bytearray (GH-5342)INADA Naoki2018-01-271-1/+1
|
* #27364: fix "incorrect" uses of escape character in the stdlib.R David Murray2016-09-081-1/+1
| | | | | | | And most of the tools. Patch by Emanual Barry, reviewed by me, Serhiy Storchaka, and Martin Panter.
* Backed out changeset af29d89083b3 (closes #25548) (closes #27498)Benjamin Peterson2016-07-141-1/+1
|
* Issue #18300: Merge from 3.5Berker Peksag2016-06-241-15/+9
|\
| * Issue #18300: Set TERM='' by default in assert_python_*Berker Peksag2016-06-241-15/+9
| |
* | Issue #25548: Showing memory address of class objects in replKushal Das2016-06-041-1/+1
| |
* | Issue #27076: Merge spelling from 3.5Martin Panter2016-05-261-1/+1
|\ \ | |/
| * Issue #27076: Doc, comment and tests spelling fixesMartin Panter2016-05-261-1/+1
| | | | | | | | Most fixes to Doc/ and Lib/ directories by Ville Skyttä.
* | Issue #23277: Remove unused imports in tests.Serhiy Storchaka2016-04-241-3/+1
| |
* | test_doctest: remove unused importsVictor Stinner2016-03-251-2/+1
|/
* Issue #26304: Change "allows to <verb>" to "allows <verb>ing" or similarMartin Panter2016-02-101-1/+1
| | | | | The original form is incorrect grammar and feels awkward, even though the meaning is clear.
* Fix test_doctest in verbose modeVictor Stinner2015-12-021-2/+2
|
* Issue #9517: Move script_helper to the support package.Berker Peksag2015-05-061-4/+4
| | | | Patch by Christie Wilson.
* Implements issue #9951: Adds a hex() method to bytes, bytearray, & memoryview.Gregory P. Smith2015-04-251-1/+1
| | | | | | | Also updates a few internal implementations of the same thing to use the new built-in code. Contributed by Arnon Yaari.
* Issue #23943: Fix typos. Patch by Piotr Kasprzyk.Berker Peksag2015-04-141-2/+2
|\
| * Issue #23943: Fix typos. Patch by Piotr Kasprzyk.Berker Peksag2015-04-141-2/+2
| |
* | Open files in binary mode to avoid newlines transformation.Serhiy Storchaka2015-04-041-4/+4
|\ \ | |/
| * Open files in binary mode to avoid newlines transformation.Serhiy Storchaka2015-04-041-4/+4
| |
* | Issue #21740: Support wrapped callables in pydoc. Patch by Claudiu Popa.Yury Selivanov2014-12-081-1/+18
| |
* | Merge: #8473: Add tests that doctest uses universal newlines in testfile.R David Murray2014-10-031-0/+30
|\ \ | |/