From 54a9132aea663dcdc6d8deb350e3c3e3a3381907 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 4 Jan 2013 11:22:49 -0500 Subject: [PATCH] tests: Update tests after filename/filepath -> source_path --- tests/test_generators.py | 10 +++++----- tests/test_pelican.py | 4 ++-- tests/test_readers.py | 32 ++++++++++++++++---------------- tests/test_utils.py | 12 ++++++------ 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/test_generators.py b/tests/test_generators.py index 50f5fe3e..54fe7e61 100644 --- a/tests/test_generators.py +++ b/tests/test_generators.py @@ -229,20 +229,20 @@ class TestTemplatePagesGenerator(unittest.TestCase): # create a dummy template file template_dir = os.path.join(self.temp_content, 'template') - template_filename = os.path.join(template_dir, 'source.html') + template_path = os.path.join(template_dir, 'source.html') os.makedirs(template_dir) - with open(template_filename, 'w') as template_file: + with open(template_path, 'w') as template_file: template_file.write(self.TEMPLATE_CONTENT) writer = Writer(self.temp_output, settings=settings) generator.generate_output(writer) - output_filename = os.path.join( + output_path = os.path.join( self.temp_output, 'generated', 'file.html') # output file has been generated - self.assertTrue(os.path.exists(output_filename)) + self.assertTrue(os.path.exists(output_path)) # output content is correct - with open(output_filename, 'r') as output_file: + with open(output_path, 'r') as output_file: self.assertEquals(output_file.read(), 'foo: bar') diff --git a/tests/test_pelican.py b/tests/test_pelican.py index 6a082676..ca0e22cc 100644 --- a/tests/test_pelican.py +++ b/tests/test_pelican.py @@ -70,7 +70,7 @@ class TestPelican(unittest.TestCase): def test_basic_generation_works(self): # when running pelican without settings, it should pick up the default # ones and generate correct output without raising any exception - settings = read_settings(filename=None, override={ + settings = read_settings(path=None, override={ 'PATH': INPUT_PATH, 'OUTPUT_PATH': self.temp_path, 'LOCALE': locale.normalize('en_US'), @@ -86,7 +86,7 @@ class TestPelican(unittest.TestCase): def test_custom_generation_works(self): # the same thing with a specified set of settings should work - settings = read_settings(filename=SAMPLE_CONFIG, override={ + settings = read_settings(path=SAMPLE_CONFIG, override={ 'PATH': INPUT_PATH, 'OUTPUT_PATH': self.temp_path, 'LOCALE': locale.normalize('en_US'), diff --git a/tests/test_readers.py b/tests/test_readers.py index e3cea629..75e664d5 100644 --- a/tests/test_readers.py +++ b/tests/test_readers.py @@ -11,7 +11,7 @@ CUR_DIR = os.path.dirname(__file__) CONTENT_PATH = os.path.join(CUR_DIR, 'content') -def _filename(*args): +def _path(*args): return os.path.join(CONTENT_PATH, *args) @@ -19,7 +19,7 @@ class RstReaderTest(unittest.TestCase): def test_article_with_metadata(self): reader = readers.RstReader({}) - content, metadata = reader.read(_filename('article_with_metadata.rst')) + content, metadata = reader.read(_path('article_with_metadata.rst')) expected = { 'category': 'yeah', 'author': 'Alexis Métaireau', @@ -37,7 +37,7 @@ class RstReaderTest(unittest.TestCase): def test_article_with_filename_metadata(self): content, metadata = readers.read_file( - _filename('2012-11-29_rst_w_filename_meta#foo-bar.rst'), + _path('2012-11-29_rst_w_filename_meta#foo-bar.rst'), settings={}) expected = { 'category': 'yeah', @@ -48,7 +48,7 @@ class RstReaderTest(unittest.TestCase): self.assertEquals(value, expected[key], key) content, metadata = readers.read_file( - _filename('2012-11-29_rst_w_filename_meta#foo-bar.rst'), + _path('2012-11-29_rst_w_filename_meta#foo-bar.rst'), settings={ 'FILENAME_METADATA': '(?P\d{4}-\d{2}-\d{2}).*' }) @@ -62,7 +62,7 @@ class RstReaderTest(unittest.TestCase): self.assertEquals(value, expected[key], key) content, metadata = readers.read_file( - _filename('2012-11-29_rst_w_filename_meta#foo-bar.rst'), + _path('2012-11-29_rst_w_filename_meta#foo-bar.rst'), settings={ 'FILENAME_METADATA': '(?P\d{4}-\d{2}-\d{2})_' \ '_(?P.*)' \ @@ -82,7 +82,7 @@ class RstReaderTest(unittest.TestCase): def test_article_metadata_key_lowercase(self): """Keys of metadata should be lowercase.""" reader = readers.RstReader({}) - content, metadata = reader.read(_filename('article_with_uppercase_metadata.rst')) + content, metadata = reader.read(_path('article_with_uppercase_metadata.rst')) self.assertIn('category', metadata, "Key should be lowercase.") self.assertEquals('Yeah', metadata.get('category'), "Value keeps cases.") @@ -90,7 +90,7 @@ class RstReaderTest(unittest.TestCase): def test_typogrify(self): # if nothing is specified in the settings, the content should be # unmodified - content, _ = readers.read_file(_filename('article.rst')) + content, _ = readers.read_file(_path('article.rst')) expected = "

This is some content. With some stuff to "\ ""typogrify".

\n

Now with added "\ 'support for '\ @@ -100,7 +100,7 @@ class RstReaderTest(unittest.TestCase): try: # otherwise, typogrify should be applied - content, _ = readers.read_file(_filename('article.rst'), + content, _ = readers.read_file(_path('article.rst'), settings={'TYPOGRIFY': True}) expected = "

This is some content. With some stuff to "\ "“typogrify”.

\n

Now with added "\ @@ -118,7 +118,7 @@ class MdReaderTest(unittest.TestCase): def test_article_with_md_extension(self): # test to ensure the md extension is being processed by the correct reader reader = readers.MarkdownReader({}) - content, metadata = reader.read(_filename('article_with_md_extension.md')) + content, metadata = reader.read(_path('article_with_md_extension.md')) expected = "

Test Markdown File Header

\n"\ "

Used for pelican test

\n"\ "

The quick brown fox jumped over the lazy dog's back.

" @@ -136,7 +136,7 @@ class MdReaderTest(unittest.TestCase): def test_article_with_mkd_extension(self): # test to ensure the mkd extension is being processed by the correct reader reader = readers.MarkdownReader({}) - content, metadata = reader.read(_filename('article_with_mkd_extension.mkd')) + content, metadata = reader.read(_path('article_with_mkd_extension.mkd')) expected = "

Test Markdown File Header

\n"\ "

Used for pelican test

\n"\ "

This is another markdown test file. Uses the mkd extension.

" @@ -147,7 +147,7 @@ class MdReaderTest(unittest.TestCase): def test_article_with_markdown_markup_extension(self): # test to ensure the markdown markup extension is being processed as expected content, metadata = readers.read_file( - _filename('article_with_markdown_markup_extensions.md'), + _path('article_with_markdown_markup_extensions.md'), settings={'MD_EXTENSIONS': ['toc', 'codehilite', 'extra']}) expected = '
\n'\ '
    \n'\ @@ -165,7 +165,7 @@ class MdReaderTest(unittest.TestCase): @unittest.skipUnless(readers.Markdown, "markdown isn't installed") def test_article_with_filename_metadata(self): content, metadata = readers.read_file( - _filename('2012-11-30_md_w_filename_meta#foo-bar.md'), + _path('2012-11-30_md_w_filename_meta#foo-bar.md'), settings={}) expected = { 'category': 'yeah', @@ -175,7 +175,7 @@ class MdReaderTest(unittest.TestCase): self.assertEquals(value, metadata[key], key) content, metadata = readers.read_file( - _filename('2012-11-30_md_w_filename_meta#foo-bar.md'), + _path('2012-11-30_md_w_filename_meta#foo-bar.md'), settings={ 'FILENAME_METADATA': '(?P\d{4}-\d{2}-\d{2}).*' }) @@ -188,7 +188,7 @@ class MdReaderTest(unittest.TestCase): self.assertEquals(value, metadata[key], key) content, metadata = readers.read_file( - _filename('2012-11-30_md_w_filename_meta#foo-bar.md'), + _path('2012-11-30_md_w_filename_meta#foo-bar.md'), settings={ 'FILENAME_METADATA': '(?P\d{4}-\d{2}-\d{2})' '_(?P.*)' @@ -210,7 +210,7 @@ class AdReaderTest(unittest.TestCase): def test_article_with_asc_extension(self): # test to ensure the asc extension is being processed by the correct reader reader = readers.AsciiDocReader({}) - content, metadata = reader.read(_filename('article_with_asc_extension.asc')) + content, metadata = reader.read(_path('article_with_asc_extension.asc')) expected = '
    \n

    Used for pelican test

    \n'\ '

    The quick brown fox jumped over the lazy dog’s back.

    \n' self.assertEqual(content, expected) @@ -241,7 +241,7 @@ class AdReaderTest(unittest.TestCase): def test_article_with_asc_options(self): # test to ensure the ASCIIDOC_OPTIONS is being used reader = readers.AsciiDocReader(dict(ASCIIDOC_OPTIONS=["-a revision=1.0.42"])) - content, metadata = reader.read(_filename('article_with_asc_options.asc')) + content, metadata = reader.read(_path('article_with_asc_options.asc')) expected = '
    \n

    Used for pelican test

    \n'\ '

    version 1.0.42

    \n'\ '

    The quick brown fox jumped over the lazy dog’s back.

    \n' diff --git a/tests/test_utils.py b/tests/test_utils.py index eddb3e25..ea4f839c 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -79,17 +79,17 @@ class TestUtils(unittest.TestCase): """Test if file changes are correctly detected Make sure to handle not getting any files correctly""" - path = os.path.join(os.path.dirname(__file__), 'content') - filename = os.path.join(path, 'article_with_metadata.rst') - changed = utils.files_changed(path, 'rst') + dirname = os.path.join(os.path.dirname(__file__), 'content') + path = os.path.join(dirname, 'article_with_metadata.rst') + changed = utils.files_changed(dirname, 'rst') self.assertEquals(changed, True) - changed = utils.files_changed(path, 'rst') + changed = utils.files_changed(dirname, 'rst') self.assertEquals(changed, False) t = time.time() - os.utime(filename, (t, t)) - changed = utils.files_changed(path, 'rst') + os.utime(path, (t, t)) + changed = utils.files_changed(dirname, 'rst') self.assertEquals(changed, True) self.assertAlmostEqual(utils.LAST_MTIME, t, delta=1)