Skip to content

gh-54434: Execute difflib.rst doctests in our test suite #111680

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Nov 3, 2023

Now this file will always be executed on test_difflib, which will protect us from future problems.

It passes in both test-running styles:

» ./python.exe -m test test_difflib
Using random seed: 693048103
0:00:00 load avg: 1.81 Run 1 test sequentially
0:00:00 load avg: 1.81 [1/1] test_difflib

== Tests result: SUCCESS ==

1 test OK.

Total duration: 584 ms
Total tests: run=52
Total test files: run=1/1
Result: SUCCESS
» ./python.exe Lib/test/test_difflib.py
....................................................
----------------------------------------------------------------------
Ran 52 tests in 0.569s

OK

@sobolevn sobolevn requested a review from terryjreedy November 3, 2023 07:25
@bedevere-app bedevere-app bot added the tests Tests in the Lib/test dir label Nov 3, 2023
@terryjreedy
Copy link
Member

Re-running unrelated failures.

Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When fixing difflib.rst doctests, I used doctest.testfile, which a) runs the tests without any extra sphinx directive and b) reported that there were 47 tests. (I am not sure if that counts 'statements' or 'contiguous statement blocks, but this does not matter here.) DocTestSuite appears to count each docstring as one test. Running with -v:

...  # Normal unittests
Differ (difflib)
Doctest: difflib.Differ ... ok
_fancy_replace (difflib.Differ)
Doctest: difflib.Differ._fancy_replace ... ok
...  # Other docstring tests
unified_diff (difflib)
Doctest: difflib.unified_diff ... ok

DocFileSuite sees the entire file essentially 1 docstring (sort of sensible) and therefore as 1 test (instead of the 47 reported by testfile. At the end of -v output:

f:\dev\3x\Doc/library/difflib.rst
Doctest: difflib.rst ... ok

However, this is enough, I believe, to show that the added tests were run.
Getting 51 instead of 52 tests run on main (without -v) says the same.

I suspect that many of the tests are more or less the same in docstring and doc, but supposedly duplicate copies both need testing.

@terryjreedy
Copy link
Member

Unreleated test.test_asyncio.test_streams again 'altered the execution environment (env changed):'.

@sobolevn
Copy link
Member Author

sobolevn commented Nov 4, 2023

@terryjreedy oh, I am sorry, there's a bigger thing! Please, take a look at #111704

We have a wider problem: many doctests are not executed and have problems.
So, I think we should ignore this PR for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants