|
@@ -12,6 +12,7 @@ import subprocess
|
|
|
|
|
|
from pelican import Pelican
|
|
from pelican import Pelican
|
|
from pelican.settings import read_settings
|
|
from pelican.settings import read_settings
|
|
|
|
+from pelican.tests.support import mute, skipIfNoExecutable, module_exists
|
|
|
|
|
|
CUR_DIR = os.path.dirname(__file__)
|
|
CUR_DIR = os.path.dirname(__file__)
|
|
THEME_DIR = os.path.join(CUR_DIR, 'test_data')
|
|
THEME_DIR = os.path.join(CUR_DIR, 'test_data')
|
|
@@ -20,37 +21,6 @@ CSS_REF = open(os.path.join(THEME_DIR, 'static', 'css',
|
|
CSS_HASH = hashlib.md5(CSS_REF).hexdigest()[0:8]
|
|
CSS_HASH = hashlib.md5(CSS_REF).hexdigest()[0:8]
|
|
|
|
|
|
|
|
|
|
-def skipIfNoExecutable(executable):
|
|
|
|
- """Skip test if `executable` is not found
|
|
|
|
-
|
|
|
|
- Tries to run `executable` with subprocess to make sure it's in the path,
|
|
|
|
- and skips the tests if not found (if subprocess raises a `OSError`).
|
|
|
|
- """
|
|
|
|
-
|
|
|
|
- with open(os.devnull, 'w') as fnull:
|
|
|
|
- try:
|
|
|
|
- res = subprocess.call(executable, stdout=fnull, stderr=fnull)
|
|
|
|
- except OSError:
|
|
|
|
- res = None
|
|
|
|
-
|
|
|
|
- if res is None:
|
|
|
|
- return unittest.skip('{0} executable not found'.format(executable))
|
|
|
|
-
|
|
|
|
- return lambda func: func
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-def module_exists(module_name):
|
|
|
|
- """Test if a module is importable."""
|
|
|
|
-
|
|
|
|
- try:
|
|
|
|
- __import__(module_name)
|
|
|
|
- except ImportError:
|
|
|
|
- return False
|
|
|
|
- else:
|
|
|
|
- return True
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
@unittest.skipUnless(module_exists('webassets'), "webassets isn't installed")
|
|
@unittest.skipUnless(module_exists('webassets'), "webassets isn't installed")
|
|
@skipIfNoExecutable(['scss', '-v'])
|
|
@skipIfNoExecutable(['scss', '-v'])
|
|
@skipIfNoExecutable(['cssmin', '--version'])
|
|
@skipIfNoExecutable(['cssmin', '--version'])
|
|
@@ -66,13 +36,14 @@ class TestWebAssets(unittest.TestCase):
|
|
'PLUGINS': [assets],
|
|
'PLUGINS': [assets],
|
|
'THEME': THEME_DIR,
|
|
'THEME': THEME_DIR,
|
|
'LOCALE': locale.normalize('en_US'),
|
|
'LOCALE': locale.normalize('en_US'),
|
|
|
|
+ 'CACHE_CONTENT': False
|
|
}
|
|
}
|
|
if override:
|
|
if override:
|
|
settings.update(override)
|
|
settings.update(override)
|
|
|
|
|
|
self.settings = read_settings(override=settings)
|
|
self.settings = read_settings(override=settings)
|
|
pelican = Pelican(settings=self.settings)
|
|
pelican = Pelican(settings=self.settings)
|
|
- pelican.run()
|
|
|
|
|
|
+ mute(True)(pelican.run)()
|
|
|
|
|
|
def tearDown(self):
|
|
def tearDown(self):
|
|
rmtree(self.temp_path)
|
|
rmtree(self.temp_path)
|