fixed handling empty tags in TXT file
This commit is contained in:
@@ -556,6 +556,15 @@ This is an answer.
|
||||
This is a question.
|
||||
{Answer.txt_header}
|
||||
This is an answer.
|
||||
""")
|
||||
self.file_txt_tags_empty = tempfile.NamedTemporaryFile(delete=False, suffix='.txt')
|
||||
self.file_path_txt_tags_empty = pathlib.Path(self.file_txt_tags_empty.name)
|
||||
with open(self.file_path_txt_tags_empty, "w") as fd:
|
||||
fd.write(f"""TAGS:
|
||||
{Question.txt_header}
|
||||
This is a question.
|
||||
{Answer.txt_header}
|
||||
This is an answer.
|
||||
""")
|
||||
self.file_yaml = tempfile.NamedTemporaryFile(delete=False, suffix='.yaml')
|
||||
self.file_path_yaml = pathlib.Path(self.file_yaml.name)
|
||||
@@ -594,6 +603,10 @@ This is an answer.
|
||||
tags = Message.tags_from_file(self.file_path_txt_no_tags)
|
||||
self.assertSetEqual(tags, set())
|
||||
|
||||
def test_tags_from_file_txt_tags_empty(self) -> None:
|
||||
tags = Message.tags_from_file(self.file_path_txt_tags_empty)
|
||||
self.assertSetEqual(tags, set())
|
||||
|
||||
def test_tags_from_file_yaml(self) -> None:
|
||||
tags = Message.tags_from_file(self.file_path_yaml)
|
||||
self.assertSetEqual(tags, {Tag('tag1'), Tag('tag2'), Tag('ptag3')})
|
||||
|
||||
@@ -44,6 +44,10 @@ class TestTagLine(CmmTestCase):
|
||||
tags = tagline.tags()
|
||||
self.assertEqual(tags, {Tag('atag1'), Tag('btag2')})
|
||||
|
||||
def test_tags_empty(self) -> None:
|
||||
tagline = TagLine('TAGS:')
|
||||
self.assertSetEqual(tagline.tags(), set())
|
||||
|
||||
def test_tags_with_newline(self) -> None:
|
||||
tagline = TagLine('TAGS: tag1\n tag2')
|
||||
tags = tagline.tags()
|
||||
|
||||
Reference in New Issue
Block a user