Apply formatting scripts.
All checks were successful
Testing / pytest (push) Successful in 27s
Testing / mypy (push) Successful in 29s
Testing / style-formatting (push) Successful in 29s
Testing / style-sorted-imports (push) Successful in 23s
Testing / stability-extra-test (push) Successful in 28s

This commit is contained in:
Sergio Martínez Portela 2024-10-07 19:48:16 +02:00
parent 56416f2fd8
commit 15af4212ae
3 changed files with 29 additions and 20 deletions

View file

@ -903,8 +903,8 @@ class TestSerde(unittest.TestCase):
# Update
lines = list(doc.dump_headline(hl, recursive=False))
assert lines[0].startswith('* ') # Title, skip it
content = '\n'.join(lines[1:])
assert lines[0].startswith("* ") # Title, skip it
content = "\n".join(lines[1:])
hl.update_raw_contents(content)
# Check after update
@ -914,7 +914,7 @@ class TestSerde(unittest.TestCase):
with open(os.path.join(DIR, "13-update-reparse-test.org")) as f:
doc = load(f)
expected_hl_contents = ''' :PROPERTIES:
expected_hl_contents = """ :PROPERTIES:
:ID: 13-update-reparse-first-level-id
:CREATED: [2020-01-01 Wed 01:01]
:END:
@ -924,12 +924,12 @@ class TestSerde(unittest.TestCase):
- With a sublist
Something after the list.
'''
"""
hl = doc.getTopHeadlines()[0]
lines = list(doc.dump_headline(hl, recursive=False))
assert lines[0].startswith('* ') # Title, skip it
content = '\n'.join(lines[1:])
assert lines[0].startswith("* ") # Title, skip it
content = "\n".join(lines[1:])
self.assertEqual(content, expected_hl_contents)
# Check after update
@ -937,17 +937,17 @@ class TestSerde(unittest.TestCase):
self.assertEqual(content, expected_hl_contents)
# Check after dump and reload
with tempfile.NamedTemporaryFile('wt') as f:
with tempfile.NamedTemporaryFile("wt") as f:
save = org_rw.dumps(doc)
f.write(save)
f.flush()
with open(f.name, 'rt') as reader:
with open(f.name, "rt") as reader:
reloaded = org_rw.load(reader)
re_hl = reloaded.getTopHeadlines()[0]
lines = list(doc.dump_headline(hl, recursive=False))
assert lines[0].startswith('* ') # Title, skip it
content = '\n'.join(lines[1:])
assert lines[0].startswith("* ") # Title, skip it
content = "\n".join(lines[1:])
self.assertEqual(content, expected_hl_contents)
def test_mimic_write_file_13(self):

View file

@ -67,7 +67,12 @@ class HL:
self.content = content
self.children = children
def assert_matches(self, test_case: unittest.TestCase, doc, accept_trailing_whitespace_changes=False):
def assert_matches(
self,
test_case: unittest.TestCase,
doc,
accept_trailing_whitespace_changes=False,
):
test_case.assertEqual(self.title, get_raw(doc.title))
# Check properties
@ -85,7 +90,9 @@ class HL:
)
if accept_trailing_whitespace_changes:
test_case.assertEqual(get_raw_contents(doc).rstrip(), self.get_raw().rstrip())
test_case.assertEqual(
get_raw_contents(doc).rstrip(), self.get_raw().rstrip()
)
else:
test_case.assertEqual(get_raw_contents(doc), self.get_raw())