mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge branch 'pr/558'
Conflicts: docs/settings.rst pelican/signals.py
This commit is contained in:
commit
801bc755b5
16 changed files with 298 additions and 244 deletions
|
|
@ -2,15 +2,16 @@
|
|||
|
||||
from mock import MagicMock
|
||||
import os
|
||||
import re
|
||||
|
||||
from codecs import open
|
||||
from tempfile import mkdtemp
|
||||
from shutil import rmtree
|
||||
|
||||
from pelican.generators import ArticlesGenerator, LessCSSGenerator, \
|
||||
PagesGenerator, TemplatePagesGenerator
|
||||
from pelican.generators import ArticlesGenerator, PagesGenerator, \
|
||||
TemplatePagesGenerator
|
||||
from pelican.writers import Writer
|
||||
from pelican.settings import _DEFAULT_CONFIG
|
||||
from .support import unittest, skipIfNoExecutable
|
||||
from .support import unittest
|
||||
|
||||
CUR_DIR = os.path.dirname(__file__)
|
||||
|
||||
|
|
@ -238,55 +239,3 @@ class TestTemplatePagesGenerator(unittest.TestCase):
|
|||
# output content is correct
|
||||
with open(output_filename, 'r') as output_file:
|
||||
self.assertEquals(output_file.read(), 'foo: bar')
|
||||
|
||||
|
||||
class TestLessCSSGenerator(unittest.TestCase):
|
||||
|
||||
LESS_CONTENT = """
|
||||
@color: #4D926F;
|
||||
|
||||
#header {
|
||||
color: @color;
|
||||
}
|
||||
h2 {
|
||||
color: @color;
|
||||
}
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.temp_content = mkdtemp()
|
||||
self.temp_output = mkdtemp()
|
||||
|
||||
def tearDown(self):
|
||||
rmtree(self.temp_content)
|
||||
rmtree(self.temp_output)
|
||||
|
||||
@skipIfNoExecutable('lessc')
|
||||
def test_less_compiler(self):
|
||||
|
||||
settings = _DEFAULT_CONFIG.copy()
|
||||
settings['STATIC_PATHS'] = ['static']
|
||||
settings['LESS_GENERATOR'] = True
|
||||
|
||||
generator = LessCSSGenerator(None, settings, self.temp_content,
|
||||
_DEFAULT_CONFIG['THEME'], self.temp_output, None)
|
||||
|
||||
# create a dummy less file
|
||||
less_dir = os.path.join(self.temp_content, 'static', 'css')
|
||||
less_filename = os.path.join(less_dir, 'test.less')
|
||||
|
||||
less_output = os.path.join(self.temp_output, 'static', 'css',
|
||||
'test.css')
|
||||
|
||||
os.makedirs(less_dir)
|
||||
with open(less_filename, 'w') as less_file:
|
||||
less_file.write(self.LESS_CONTENT)
|
||||
|
||||
generator.generate_output()
|
||||
|
||||
# we have the file ?
|
||||
self.assertTrue(os.path.exists(less_output))
|
||||
|
||||
# was it compiled ?
|
||||
self.assertIsNotNone(re.search(r'^\s+color:\s*#4D926F;$',
|
||||
open(less_output).read(), re.MULTILINE | re.IGNORECASE))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue