forked from github/pelican
Convert '.' and '..' to the less magical os.curdir and os.pardir
While I'm cleaning up path manipulation, I might as well make things more semantic.
This commit is contained in:
parent
a5c1fdac58
commit
b59da89e80
10 changed files with 19 additions and 16 deletions
|
|
@ -14,7 +14,7 @@ from pelican.tests.support import LoggedTestCase
|
|||
|
||||
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
SAMPLES_PATH = os.path.abspath(os.path.join(
|
||||
CURRENT_DIR, '..', '..', 'samples'))
|
||||
CURRENT_DIR, os.pardir, os.pardir, 'samples'))
|
||||
OUTPUT_PATH = os.path.abspath(os.path.join(CURRENT_DIR, 'output'))
|
||||
|
||||
INPUT_PATH = os.path.join(SAMPLES_PATH, "content")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals, print_function
|
||||
import copy
|
||||
import os
|
||||
from os.path import dirname, abspath, join
|
||||
|
||||
from pelican.settings import (read_settings, configure_settings,
|
||||
|
|
@ -62,7 +63,7 @@ class TestSettingsConfiguration(unittest.TestCase):
|
|||
settings = {
|
||||
'SITEURL': 'http://blog.notmyidea.org/',
|
||||
'LOCALE': '',
|
||||
'PATH': '.',
|
||||
'PATH': os.curdir,
|
||||
'THEME': DEFAULT_THEME,
|
||||
}
|
||||
configure_settings(settings)
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ class TestUtils(LoggedTestCase):
|
|||
|
||||
def test_get_relative_path(self):
|
||||
|
||||
samples = (('test/test.html', '..'),
|
||||
('test/test/test.html', '../..'),
|
||||
('test.html', '.'))
|
||||
samples = (('test/test.html', os.pardir),
|
||||
('test/test/test.html', os.path.join(os.pardir, os.pardir)),
|
||||
('test.html', os.curdir))
|
||||
|
||||
for value, expected in samples:
|
||||
self.assertEquals(utils.get_relative_path(value), expected)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue