Commit 65d0193
test(exporters): fix flaky DOCX byte-comparison tests — compare content not raw bytes
Two tests in test_exporters.py compared raw .docx bytes. A .docx is
a ZIP archive and python-docx stamps the current mtime into every
entry's local file header, so two renders a second apart differ
byte-wise even when the document content is byte-identical.
* test_export_docx_bytes_unknown_theme_falls_back_to_classic_ats
asserted `fallback_bytes == classic_bytes` — intermittently
FAILED across a DOS-timestamp 2-second boundary (~1-in-5;
surfaced as a byte diff at index ~10, the ZIP last-mod-time
field).
* test_export_docx_bytes_themes_produce_different_outputs
asserted `classic_bytes != neutral_bytes` — never failed, but
was effectively vacuous: timestamps alone guarantee the bytes
differ, so it would have passed even if the theme/palette
switch were completely broken.
Both rewritten to compare EXTRACTED document content via the
existing helpers instead of raw bytes:
- fallback test: _docx_paragraph_pairs + _docx_run_color_hexes +
_docx_run_font_names must all be EQUAL (unknown theme renders
identically to classic_ats).
- themes test: _docx_run_color_hexes must DIFFER (classic_ats
warm-brown vs professional_neutral black) — a real palette-
switch regression guard.
Deterministic now — confirmed stable 5/5 consecutive runs. 32/32
exporter tests green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent beb6f20 commit 65d0193
2 files changed
Lines changed: 44 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2799 | 2799 | | |
2800 | 2800 | | |
2801 | 2801 | | |
2802 | | - | |
2803 | | - | |
2804 | | - | |
2805 | | - | |
2806 | | - | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
866 | 866 | | |
867 | 867 | | |
868 | 868 | | |
869 | | - | |
870 | | - | |
871 | | - | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
872 | 878 | | |
873 | 879 | | |
874 | 880 | | |
875 | | - | |
| 881 | + | |
876 | 882 | | |
877 | 883 | | |
878 | | - | |
| 884 | + | |
879 | 885 | | |
880 | | - | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
881 | 889 | | |
882 | 890 | | |
883 | 891 | | |
884 | 892 | | |
885 | 893 | | |
886 | 894 | | |
887 | 895 | | |
888 | | - | |
889 | | - | |
| 896 | + | |
890 | 897 | | |
891 | 898 | | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | | - | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
897 | 911 | | |
898 | 912 | | |
899 | 913 | | |
| |||
0 commit comments