Allow trailing whitespace changes on raw content update.
All checks were successful
Testing / pytest (push) Successful in 28s
Testing / mypy (push) Successful in 31s
Testing / stability-extra-test (push) Successful in 31s

This commit is contained in:
Sergio Martínez Portela 2024-07-30 10:52:37 +02:00
parent d0498d2f5b
commit ef615feac5
2 changed files with 6 additions and 3 deletions

View File

@ -903,7 +903,7 @@ class TestSerde(unittest.TestCase):
hl.update_raw_contents(content) hl.update_raw_contents(content)
# Check after update # Check after update
ex.assert_matches(self, hl) ex.assert_matches(self, hl, accept_trailing_whitespace_changes=True)
def print_tree(tree, indentation=0, headline=None): def print_tree(tree, indentation=0, headline=None):

View File

@ -58,7 +58,7 @@ class HL:
self.content = content self.content = content
self.children = children self.children = children
def assert_matches(self, test_case: unittest.TestCase, doc): def assert_matches(self, test_case: unittest.TestCase, doc, accept_trailing_whitespace_changes=False):
test_case.assertEqual(self.title, get_raw(doc.title)) test_case.assertEqual(self.title, get_raw(doc.title))
# Check properties # Check properties
@ -75,6 +75,9 @@ class HL:
timestamp_to_datetime(doc_props[i].value), prop[1] timestamp_to_datetime(doc_props[i].value), prop[1]
) )
if accept_trailing_whitespace_changes:
test_case.assertEqual(get_raw_contents(doc).rstrip(), self.get_raw().rstrip())
else:
test_case.assertEqual(get_raw_contents(doc), self.get_raw()) test_case.assertEqual(get_raw_contents(doc), self.get_raw())
# Check children # Check children