allows pelican-themes symlink command to use relative paths not beginning with a dot

This commit is contained in:
Jacob Lyles 2014-02-09 00:36:52 -08:00
commit 95cacd904f
3 changed files with 26 additions and 1 deletions

View file

@ -0,0 +1 @@
this is a test

View file

@ -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))

View file

@ -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)))