-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
test_doctest
cannot be run directly: let's remove this option
#111348
Comments
…ve `test_coverage`
Same for me on Windows. |
Related: #104057 |
Testing doctest with doctest is a bold move, but it means that if a test fails, we don't know if the bug is in doctest or test_doctest unless tests pass, we edit either one but not both, and then tests fail. In this case, it is unclear if running the tests this way ever worked, and if so, what change made it fail. When a doctest fails because the expected string is overly specific (here, when name is 'main'), then it seems likely to me that the test is buggy and should be fixed. If a specific test is too hard to fix, or inapplicable, it could be skipped. From #104057, it seems there are several reasons for failure; some seem easy to fix, some less so. We have not collectively settled on a policy of when to disable direct running. Unless the coverage module cannot work with test_doctest, I do not see any reason to have custom code in just this file. |
I ran coverage: 84% for me. Perhap 1% is the function called '_test' although it looks like it should be be renamed 'main' since it enables running doctest on files from a command line (and should be tested). Note: the obvious way to me to get coverage is to run a test directly. However, I might look at the test failures later today. |
@terryjreedy We actually fixed failures in the PR (by "we" I mean @skirpichev 😆). |
Yes. |
I assume it's for coveragepy (and with |
…est.test_coverage` (#111349) 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]>
…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]>
Package is now called just 'coverage'. https://pypi.org/project/coverage/ Now 7.3.2, I have 7.2.6 EDIT: 987 appears to be logical rather than physical lines. I noticed that logical lines are only marked on the first physical line. Not sure if this was always the case. |
…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]>
I think it is: https://devguide.python.org/testing/coverage/#install-coverage BTW, I think this issue can be closed. But there could be a different one: for improving test coverage of doctest.py. Some public functions aren't tested at all (e.g. |
I agree, we've fixed the bug that this issue was about. Let's continue the discussion about improving coverage in a separate issue 👍 |
…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]>
Bug report
When running
./python.exe Lib/test/test_doctest.py
you get:These issues are not easy to fix. Moreover, since they are literally written in docstrings, it is not very readable.
The second problem is that
-c
option is claimed to be supported:cpython/Lib/test/test_doctest.py
Lines 3365 to 3380 in 78e6d72
However:
test_main
is not defined, so it failsunittest.main()
(with all of the other test failures fixed), it still does not work on macos sonoma, no file is created, nothingI propose to:
test_doctest
directly is not supportedtest_coverage
Linked PRs
test_doctest
; removetest_doctest.test_coverage
#111349test_doctest
; removetest_doctest.test_coverage
(GH-111349) #111359test_doctest
; removetest_doctest.test_coverage
(GH-111349) #111360The text was updated successfully, but these errors were encountered: