Nitpicking - tempdir naming, also backslashes are bad

Tempdirs should have useful prefixes to aid in collecting information
    about failed tests.
Implicit concatenation is better than backslash line continuation.
This commit is contained in:
Colin Dunklau 2013-03-26 00:38:07 -05:00
commit edbac49f2b
4 changed files with 38 additions and 37 deletions

View file

@ -8,8 +8,8 @@ from codecs import open
from tempfile import mkdtemp from tempfile import mkdtemp
from shutil import rmtree from shutil import rmtree
from pelican.generators import ArticlesGenerator, PagesGenerator, \ from pelican.generators import (ArticlesGenerator, PagesGenerator,
TemplatePagesGenerator TemplatePagesGenerator)
from pelican.writers import Writer from pelican.writers import Writer
from pelican.settings import _DEFAULT_CONFIG from pelican.settings import _DEFAULT_CONFIG
from pelican.tests.support import unittest, get_settings from pelican.tests.support import unittest, get_settings
@ -219,8 +219,8 @@ class TestTemplatePagesGenerator(unittest.TestCase):
TEMPLATE_CONTENT = "foo: {{ foo }}" TEMPLATE_CONTENT = "foo: {{ foo }}"
def setUp(self): def setUp(self):
self.temp_content = mkdtemp() self.temp_content = mkdtemp(prefix='pelicantests.')
self.temp_output = mkdtemp() self.temp_output = mkdtemp(prefix='pelicantests.')
def tearDown(self): def tearDown(self):
rmtree(self.temp_content) rmtree(self.temp_content)

View file

@ -42,7 +42,7 @@ class TestPelican(LoggedTestCase):
def setUp(self): def setUp(self):
super(TestPelican, self).setUp() super(TestPelican, self).setUp()
self.temp_path = mkdtemp() self.temp_path = mkdtemp(prefix='pelicantests.')
self.old_locale = locale.setlocale(locale.LC_ALL) self.old_locale = locale.setlocale(locale.LC_ALL)
self.maxDiff = None self.maxDiff = None
locale.setlocale(locale.LC_ALL, str('C')) locale.setlocale(locale.LC_ALL, str('C'))
@ -53,12 +53,12 @@ class TestPelican(LoggedTestCase):
super(TestPelican, self).tearDown() super(TestPelican, self).tearDown()
def assertFilesEqual(self, diff): def assertFilesEqual(self, diff):
msg = "some generated files differ from the expected functional " \ msg = ("some generated files differ from the expected functional "
"tests output.\n" \ "tests output.\n"
"This is probably because the HTML generated files " \ "This is probably because the HTML generated files "
"changed. If these changes are normal, please refer " \ "changed. If these changes are normal, please refer "
"to docs/contribute.rst to update the expected " \ "to docs/contribute.rst to update the expected "
"output of the functional tests." "output of the functional tests.")
self.assertEqual(diff['left_only'], [], msg=msg) self.assertEqual(diff['left_only'], [], msg=msg)
self.assertEqual(diff['right_only'], [], msg=msg) self.assertEqual(diff['right_only'], [], msg=msg)

View file

@ -94,9 +94,9 @@ class RstReaderTest(unittest.TestCase):
# unmodified # unmodified
content, _ = readers.read_file(_path('article.rst')) content, _ = readers.read_file(_path('article.rst'))
expected = ('<p>This is some content. With some stuff to ' expected = ('<p>This is some content. With some stuff to '
'&quot;typogrify&quot;.</p>\n<p>Now with added ' '&quot;typogrify&quot;.</p>\n<p>Now with added '
'support for <abbr title="three letter acronym">' 'support for <abbr title="three letter acronym">'
'TLA</abbr>.</p>\n') 'TLA</abbr>.</p>\n')
self.assertEqual(content, expected) self.assertEqual(content, expected)
@ -138,25 +138,26 @@ class MdReaderTest(unittest.TestCase):
# correct reader # correct reader
content, metadata = reader.read( content, metadata = reader.read(
_path('article_with_md_extension.md')) _path('article_with_md_extension.md'))
expected = "<h1>Test Markdown File Header</h1>\n"\ expected = (
"<h2>Used for pelican test</h2>\n"\ "<h1>Test Markdown File Header</h1>\n"
"<p>The quick brown fox jumped over the lazy dog's back.</p>" "<h2>Used for pelican test</h2>\n"
"<p>The quick brown fox jumped over the lazy dog's back.</p>")
self.assertEqual(content, expected) self.assertEqual(content, expected)
# test to ensure the mkd file extension is being processed by the # test to ensure the mkd file extension is being processed by the
# correct reader # correct reader
content, metadata = reader.read( content, metadata = reader.read(
_path('article_with_mkd_extension.mkd')) _path('article_with_mkd_extension.mkd'))
expected = "<h1>Test Markdown File Header</h1>\n<h2>Used for pelican"\ expected = ("<h1>Test Markdown File Header</h1>\n<h2>Used for pelican"
" test</h2>\n<p>This is another markdown test file. Uses"\ " test</h2>\n<p>This is another markdown test file. Uses"
" the mkd extension.</p>" " the mkd extension.</p>")
self.assertEqual(content, expected) self.assertEqual(content, expected)
# test to ensure the markdown file extension is being processed by the # test to ensure the markdown file extension is being processed by the
# correct reader # correct reader
content, metadata = reader.read( content, metadata = reader.read(
_path('article_with_markdown_extension.markdown')) _path('article_with_markdown_extension.markdown'))
expected = "<h1>Test Markdown File Header</h1>\n<h2>Used for pelican"\ expected = ("<h1>Test Markdown File Header</h1>\n<h2>Used for pelican"
" test</h2>\n<p>This is another markdown test file. Uses"\ " test</h2>\n<p>This is another markdown test file. Uses"
" the markdown extension.</p>" " the markdown extension.</p>")
self.assertEqual(content, expected) self.assertEqual(content, expected)
@unittest.skipUnless(readers.Markdown, "markdown isn't installed") @unittest.skipUnless(readers.Markdown, "markdown isn't installed")
@ -166,16 +167,16 @@ class MdReaderTest(unittest.TestCase):
content, metadata = readers.read_file( content, metadata = readers.read_file(
_path('article_with_markdown_markup_extensions.md'), _path('article_with_markdown_markup_extensions.md'),
settings={'MD_EXTENSIONS': ['toc', 'codehilite', 'extra']}) settings={'MD_EXTENSIONS': ['toc', 'codehilite', 'extra']})
expected = '<div class="toc">\n'\ expected = ('<div class="toc">\n'
'<ul>\n'\ '<ul>\n'
'<li><a href="#level1">Level1</a><ul>\n'\ '<li><a href="#level1">Level1</a><ul>\n'
'<li><a href="#level2">Level2</a></li>\n'\ '<li><a href="#level2">Level2</a></li>\n'
'</ul>\n'\ '</ul>\n'
'</li>\n'\ '</li>\n'
'</ul>\n'\ '</ul>\n'
'</div>\n'\ '</div>\n'
'<h2 id="level1">Level1</h2>\n'\ '<h2 id="level1">Level1</h2>\n'
'<h3 id="level2">Level2</h3>' '<h3 id="level2">Level2</h3>')
self.assertEqual(content, expected) self.assertEqual(content, expected)
@ -231,9 +232,9 @@ class AdReaderTest(unittest.TestCase):
content, metadata = reader.read( content, metadata = reader.read(
_path('article_with_asc_extension.asc')) _path('article_with_asc_extension.asc'))
expected = ('<hr>\n<h2><a name="_used_for_pelican_test">' expected = ('<hr>\n<h2><a name="_used_for_pelican_test">'
'</a>Used for pelican test</h2>\n' '</a>Used for pelican test</h2>\n'
'<p>The quick brown fox jumped over' '<p>The quick brown fox jumped over'
' the lazy dog&#8217;s back.</p>\n') ' the lazy dog&#8217;s back.</p>\n')
self.assertEqual(content, expected) self.assertEqual(content, expected)
expected = { expected = {
'category': 'Blog', 'category': 'Blog',

View file

@ -25,7 +25,7 @@ class TestWebAssets(unittest.TestCase):
"""Base class for testing webassets.""" """Base class for testing webassets."""
def setUp(self, override=None): def setUp(self, override=None):
self.temp_path = mkdtemp() self.temp_path = mkdtemp(prefix='pelicantests.')
settings = { settings = {
'PATH': os.path.join(CUR_DIR, 'content', 'TestCategory'), 'PATH': os.path.join(CUR_DIR, 'content', 'TestCategory'),
'OUTPUT_PATH': self.temp_path, 'OUTPUT_PATH': self.temp_path,