-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-111348: Fix direct invocation of test_doctest
; remove test_doctest.test_coverage
#111349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ve `test_coverage`
That's what I got in the
After removing problem doctest (on this branch) diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index e51f54ef35..72f49a6834 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -2843,39 +2843,6 @@ def test_lineendings(): r"""
TestResults(failed=0, attempted=1)
>>> os.remove(fn)
-Now we test with a package loader that has a get_data method, since that
-bypasses the standard universal newline handling so doctest has to do the
-newline conversion itself; let's make sure it does so correctly (issue 1812).
-We'll write a file inside the package that has all three kinds of line endings
-in it, and use a package hook to install a custom loader; on any platform,
-at least one of the line endings will raise a ValueError for inconsistent
-whitespace if doctest does not correctly do the newline conversion.
-
- >>> from test.support import os_helper
- >>> import shutil
- >>> dn = tempfile.mkdtemp()
- >>> pkg = os.path.join(dn, "doctest_testpkg")
- >>> os.mkdir(pkg)
- >>> os_helper.create_empty_file(os.path.join(pkg, "__init__.py"))
- >>> fn = os.path.join(pkg, "doctest_testfile.txt")
- >>> with open(fn, 'wb') as f:
- ... f.write(
- ... b'Test:\r\n\r\n'
- ... b' >>> x = 1 + 1\r\n\r\n'
- ... b'Done.\r\n'
- ... b'Test:\n\n'
- ... b' >>> x = 1 + 1\n\n'
- ... b'Done.\n'
- ... b'Test:\r\r'
- ... b' >>> x = 1 + 1\r\r'
- ... b'Done.\r'
- ... )
- 95
- >>> with test_hook(dn):
- ... doctest.testfile("doctest_testfile.txt", package="doctest_testpkg", verbose=False)
- TestResults(failed=0, attempted=3)
- >>> shutil.rmtree(dn)
-
"""
def test_testmod(): r""" I got
So, at least we have some coverage for the doctest module. With coveragepy:
Apparently, we have some coverage statistics for this module. (And few new bugs...) |
@skirpichev I think that |
Because the failure that is still there is rather complex:
We would need to have some compat code there as well, while it does not bring much value (while making the test more complex and brittle) |
Hmm. That's an alias to
Yeah, but what we gain raising a RuntimeError? Someone someday will open a bug if #111348 will be closed. |
Co-authored-by: Sergey B Kirpichev <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After merging in main
, all tests pass for me locally with this PR branch when I run python Lib/test/test_doctest.py
. Nice work @sobolevn and @skirpichev!
test_doctest
to be run directly, remove test_coverage
test_doctest
; remove test_doctest.test_coverage
Thanks @sobolevn for the PR, and @AlexWaygood for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
…t_doctest.test_coverage` (pythonGH-111349) (cherry picked from commit 31c05b7) Co-authored-by: Nikita Sobolev <[email protected]> Co-authored-by: Sergey B Kirpichev <[email protected]>
…t_doctest.test_coverage` (pythonGH-111349) (cherry picked from commit 31c05b7) Co-authored-by: Nikita Sobolev <[email protected]> Co-authored-by: Sergey B Kirpichev <[email protected]>
GH-111359 is a backport of this pull request to the 3.12 branch. |
GH-111360 is a backport of this pull request to the 3.11 branch. |
…st_doctest.test_coverage` (GH-111349) (#111359) gh-111348: Fix direct invocation of `test_doctest`; remove `test_doctest.test_coverage` (GH-111349) (cherry picked from commit 31c05b7) Co-authored-by: Nikita Sobolev <[email protected]> Co-authored-by: Sergey B Kirpichev <[email protected]>
…st_doctest.test_coverage` (GH-111349) (#111360) gh-111348: Fix direct invocation of `test_doctest`; remove `test_doctest.test_coverage` (GH-111349) (cherry picked from commit 31c05b7) Co-authored-by: Nikita Sobolev <[email protected]> Co-authored-by: Sergey B Kirpichev <[email protected]>
…t_doctest.test_coverage` (python#111349) Co-authored-by: Sergey B Kirpichev <[email protected]>
…t_doctest.test_coverage` (python#111349) Co-authored-by: Sergey B Kirpichev <[email protected]>
Instead of this coverage (which is almost 20 years old https://github.com/python/cpython/blame/78e6d72e38ef4b490f0098b644454031f20ae361/Lib/test/test_doctest.py#L3365-L3373) we should work on proper
coverage.py
integration in our test suite.test_doctest
cannot be run directly: let's remove this option #111348