Commit e2f103f
Run test_difflib against both pure-Python and C implementations
When the _difflib C accelerator is built, programmatically generate a
parallel ``*_PurePython`` TestCase for each existing test class so the
same suite covers both implementations. Pure-Python coverage is
obtained by patching ``difflib.SequenceMatcher`` to
``_pydifflib.SequenceMatcher`` in setUp / restoring it in tearDown;
internal helpers like ``unified_diff`` and ``ndiff`` resolve
``SequenceMatcher`` on ``difflib`` at call time, so patching the module
attribute covers the whole pipeline.
This mirrors the dual-implementation test pattern used by test_decimal
(C* / Py* class pairs) without requiring every existing test method to
be parameterised.
``test_html_diff`` also gets a single-line fix: it depended on
``HtmlDiff._default_prefix`` starting at 0, which only held because it
ran first. Resetting the counter at the top of the test makes it
order-independent.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 39a7304 commit e2f103f
1 file changed
Lines changed: 53 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
10 | 33 | | |
11 | 34 | | |
12 | 35 | | |
| |||
201 | 224 | | |
202 | 225 | | |
203 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
204 | 231 | | |
205 | 232 | | |
206 | 233 | | |
| |||
657 | 684 | | |
658 | 685 | | |
659 | 686 | | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
660 | 713 | | |
661 | 714 | | |
0 commit comments