forked from github/pelican
test_readers: test reading empty Markdown files
This commit is contained in:
parent
129b144852
commit
85a860d5dd
4 changed files with 21 additions and 2 deletions
0
pelican/tests/content/empty.md
Normal file
0
pelican/tests/content/empty.md
Normal file
1
pelican/tests/content/empty_with_bom.md
Normal file
1
pelican/tests/content/empty_with_bom.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -56,13 +56,15 @@ class TestCache(unittest.TestCase):
|
||||||
generator.readers.read_file = MagicMock()
|
generator.readers.read_file = MagicMock()
|
||||||
generator.generate_context()
|
generator.generate_context()
|
||||||
"""
|
"""
|
||||||
4 files don't get cached because they were not valid
|
6 files don't get cached because they were not valid
|
||||||
- article_with_attributes_containing_double_quotes.html
|
- article_with_attributes_containing_double_quotes.html
|
||||||
- article_with_comments.html
|
- article_with_comments.html
|
||||||
- article_with_null_attributes.html
|
- article_with_null_attributes.html
|
||||||
- 2012-11-30_md_w_filename_meta#foo-bar.md
|
- 2012-11-30_md_w_filename_meta#foo-bar.md
|
||||||
|
- empty.md
|
||||||
|
- empty_with_bom.md
|
||||||
"""
|
"""
|
||||||
self.assertEqual(generator.readers.read_file.call_count, 4)
|
self.assertEqual(generator.readers.read_file.call_count, 6)
|
||||||
|
|
||||||
@unittest.skipUnless(MagicMock, 'Needs Mock module')
|
@unittest.skipUnless(MagicMock, 'Needs Mock module')
|
||||||
def test_article_reader_content_caching(self):
|
def test_article_reader_content_caching(self):
|
||||||
|
|
|
||||||
|
|
@ -546,6 +546,22 @@ class MdReaderTest(ReaderTest):
|
||||||
}
|
}
|
||||||
self.assertDictHasSubset(metadata, expected)
|
self.assertDictHasSubset(metadata, expected)
|
||||||
|
|
||||||
|
def test_empty_file(self):
|
||||||
|
reader = readers.MarkdownReader(settings=get_settings())
|
||||||
|
content, metadata = reader.read(
|
||||||
|
_path('empty.md'))
|
||||||
|
|
||||||
|
self.assertEqual(metadata, {})
|
||||||
|
self.assertEqual(content, '')
|
||||||
|
|
||||||
|
def test_empty_file_with_bom(self):
|
||||||
|
reader = readers.MarkdownReader(settings=get_settings())
|
||||||
|
content, metadata = reader.read(
|
||||||
|
_path('empty_with_bom.md'))
|
||||||
|
|
||||||
|
self.assertEqual(metadata, {})
|
||||||
|
self.assertEqual(content, '')
|
||||||
|
|
||||||
|
|
||||||
class HTMLReaderTest(ReaderTest):
|
class HTMLReaderTest(ReaderTest):
|
||||||
def test_article_with_comments(self):
|
def test_article_with_comments(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue