forked from github/pelican
Merge pull request #898 from saimn/fix-markup-cli
Ensure that markup is a tuple.
This commit is contained in:
commit
2188f4de68
2 changed files with 23 additions and 5 deletions
|
|
@ -97,7 +97,7 @@ class Generator(object):
|
||||||
extensions are allowed)
|
extensions are allowed)
|
||||||
"""
|
"""
|
||||||
if extensions is None:
|
if extensions is None:
|
||||||
extensions = self.markup
|
extensions = tuple(self.markup)
|
||||||
basename = os.path.basename(path)
|
basename = os.path.basename(path)
|
||||||
if extensions is False or basename.endswith(extensions):
|
if extensions is False or basename.endswith(extensions):
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals, print_function
|
from __future__ import unicode_literals, print_function
|
||||||
|
|
||||||
from mock import MagicMock
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from codecs import open
|
from codecs import open
|
||||||
from tempfile import mkdtemp
|
from mock import MagicMock
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
|
from tempfile import mkdtemp
|
||||||
|
|
||||||
from pelican.generators import (ArticlesGenerator, PagesGenerator,
|
from pelican.generators import (Generator, ArticlesGenerator, PagesGenerator,
|
||||||
TemplatePagesGenerator)
|
TemplatePagesGenerator)
|
||||||
from pelican.writers import Writer
|
from pelican.writers import Writer
|
||||||
from pelican.settings import DEFAULT_CONFIG
|
from pelican.settings import DEFAULT_CONFIG
|
||||||
|
|
@ -18,6 +17,25 @@ CUR_DIR = os.path.dirname(__file__)
|
||||||
CONTENT_DIR = os.path.join(CUR_DIR, 'content')
|
CONTENT_DIR = os.path.join(CUR_DIR, 'content')
|
||||||
|
|
||||||
|
|
||||||
|
class TestGenerator(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.settings = get_settings()
|
||||||
|
self.generator = Generator(self.settings.copy(), self.settings,
|
||||||
|
CUR_DIR, self.settings['THEME'], None,
|
||||||
|
self.settings['MARKUP'])
|
||||||
|
|
||||||
|
def test_include_path(self):
|
||||||
|
filename = os.path.join(CUR_DIR, 'content', 'article.rst')
|
||||||
|
include_path = self.generator._include_path
|
||||||
|
self.assertTrue(include_path(filename))
|
||||||
|
self.assertTrue(include_path(filename, extensions=('rst',)))
|
||||||
|
self.assertFalse(include_path(filename, extensions=('md',)))
|
||||||
|
|
||||||
|
# markup must be a tuple, test that this works also with a list
|
||||||
|
self.generator.markup = ['rst', 'md']
|
||||||
|
self.assertTrue(include_path(filename))
|
||||||
|
|
||||||
|
|
||||||
class TestArticlesGenerator(unittest.TestCase):
|
class TestArticlesGenerator(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue