1
0
Fork
You've already forked teletekst
0

Add generate_custom_diff(), generate_custom_diff_attachment() & tests #2

Merged
jochie merged 2 commits from custom_diff into main 2025年08月09日 23:30:46 +02:00
  • generate_custom_diff() creates a custom "word diff", where it looks
    for changed words across the entire blocks of "replaced"
    lines.

    Similar to 'git diff --word-diff', removed words are indicated with
    [-foo-] and added words are indicated with {+bar+}, but I'm keeping
    the lines otherwise in a unified diff form, which keeps the widths
    of the output similar to the current diffs and teletekst pages.

  • generate_custom_diff_attachment() colorizes the output from
    generate_custom_diff(). For testing purposes it will return the PIL
    image object if the http object is None.

  • Use the new functions in compare_pages -> create_update() & main().

  • tests/test_compare_pages.py introduces some basic unit tests, for
    both the original generate_diff() function and the two new
    functions.

    The tests for generate_custom_diff_attachment() are quite minimal,
    just confirming that the size is as expected.

====

  • Moved generate_custom_diff() code to a separate Python module, and
    turned into a class

  • Various changes prompted by pylint

  • generate_custom_diff_attachment() return the character height, for
    testing purposes

  • Refine the height-check of the resulting images, using the previous
    change

  • Switched unittest font to DejaVuSansMono, which the actual bot uses

  • Make sure the workflow install that font

  • Separate the two assert()s in TestCustomDiff into two subTest()s

  • Add "test" target in Makefile

  • Add "unittest" step in workflow, that uses the "test" target

- generate_custom_diff() creates a custom "word diff", where it looks for changed words across the entire blocks of "replaced" lines. Similar to 'git diff --word-diff', removed words are indicated with [-foo-] and added words are indicated with {+bar+}, but I'm keeping the lines otherwise in a unified diff form, which keeps the widths of the output similar to the current diffs and teletekst pages. - generate_custom_diff_attachment() colorizes the output from generate_custom_diff(). For testing purposes it will return the PIL image object if the http object is None. - Use the new functions in compare_pages -> create_update() & main(). - tests/test_compare_pages.py introduces some basic unit tests, for both the original generate_diff() function and the two new functions. The tests for generate_custom_diff_attachment() are quite minimal, just confirming that the size is as expected. ==== - Moved generate_custom_diff() code to a separate Python module, and turned into a class - Various changes prompted by pylint - generate_custom_diff_attachment() return the character height, for testing purposes - Refine the height-check of the resulting images, using the previous change - Switched unittest font to DejaVuSansMono, which the actual bot uses - Make sure the workflow install that font - Separate the two assert()s in TestCustomDiff into two subTest()s - Add "test" target in Makefile - Add "unittest" step in workflow, that uses the "test" target
Add generate_custom_diff(), generate_custom_diff_attachment() & tests
Some checks failed
Link Checks / build (pull_request) Failing after 1m18s
5f50184ba4
- generate_custom_diff() creates a custom "word diff", where it looks
 for changed words across the entire blocks of "replaced"
 lines.
 Similar to 'git diff --word-diff', removed words are indicated with
 [-foo-] and added words are indicated with {+bar+}, but I'm keeping
 the lines otherwise in a unified diff form, which keeps the widths
 of the output similar to the current diffs and teletekst pages.
- generate_custom_diff_attachment() colorizes the output from
 generate_custom_diff(). For testing purposes it will return the PIL
 image object if the http object is None.
- Use the new functions in compare_pages -> create_update() & main().
- tests/test_compare_pages.py introduces some basic unit tests, for
 both the original generate_diff() function and the two new
 functions.
 The tests for generate_custom_diff_attachment() are quite minimal,
 just confirming that the size is as expected.
jochie force-pushed custom_diff from 5496685f59
All checks were successful
Link Checks / build (pull_request) Successful in 1m30s
to 76ab66e1f0
All checks were successful
Link Checks / build (pull_request) Successful in 1m26s
2025年08月09日 22:48:34 +02:00
Compare
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jochie/teletekst!2
Reference in a new issue
jochie/teletekst
No description provided.
Delete branch "custom_diff"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?