diff --git a/pelican/tests/TestTheme/theme/a.html b/pelican/tests/TestTheme/theme/a.html new file mode 100644 index 00000000..90bfcb51 --- /dev/null +++ b/pelican/tests/TestTheme/theme/a.html @@ -0,0 +1 @@ +this is a test diff --git a/pelican/tests/test_pelican_themes.py b/pelican/tests/test_pelican_themes.py new file mode 100644 index 00000000..474a8ca7 --- /dev/null +++ b/pelican/tests/test_pelican_themes.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals, print_function + +import os + +from pelican.tools.pelican_themes import symlink, _THEMES_PATH +from pelican.tests.support import LoggedTestCase + +CURRENT_DIR_REL = os.path.dirname(__file__) +THEME_TARGET_PATH = os.path.join(_THEMES_PATH, "theme") + +class TestPelicanThemes(LoggedTestCase): + # testing for pelican-themes commands. + + def setUp(self): + super(TestPelicanThemes, self).setUp() + + def tearDown(self): + super(TestPelicanThemes, self).tearDown() + os.remove(THEME_TARGET_PATH) + + def test_symlink_relative(self): + symlink(os.path.join(CURRENT_DIR_REL, "TestTheme/theme/")) + self.assertTrue(os.path.exists(THEME_TARGET_PATH)) diff --git a/pelican/tools/pelican_themes.py b/pelican/tools/pelican_themes.py index 8d71535d..e2feee29 100755 --- a/pelican/tools/pelican_themes.py +++ b/pelican/tools/pelican_themes.py @@ -214,7 +214,7 @@ def symlink(path, v=False): if v: print("Linking `{p}' to `{t}' ...".format(p=path, t=theme_path)) try: - os.symlink(path, theme_path) + os.symlink(os.path.abspath(path), theme_path) except Exception as e: err("Cannot link `{p}' to `{t}':\n{e}".format(p=path, t=theme_path, e=str(e)))