diff --git a/docs/conf.py b/docs/conf.py index 53171646..fc49975a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -61,7 +61,7 @@ html_show_sourcelink = False def setup(app): # overrides for wide tables in RTD theme - app.add_stylesheet('theme_overrides.css') # path relative to _static + app.add_css_file('theme_overrides.css') # path relative to _static # -- Options for LaTeX output ------------------------------------------------- diff --git a/docs/themes.rst b/docs/themes.rst index a2332615..86a754bc 100644 --- a/docs/themes.rst +++ b/docs/themes.rst @@ -242,7 +242,7 @@ as the name of the metadata field, except in all-lowercase characters. For example, you could add a field called `FacebookImage` to your article metadata, as shown below: -.. code-block:: markdown +.. code-block:: md Title: I love Python more than music Date: 2013-11-06 10:06 diff --git a/pelican/tests/test_cache.py b/pelican/tests/test_cache.py index cc5218b7..564f1d31 100644 --- a/pelican/tests/test_cache.py +++ b/pelican/tests/test_cache.py @@ -1,17 +1,11 @@ import os from shutil import rmtree from tempfile import mkdtemp +from unittest.mock import MagicMock from pelican.generators import ArticlesGenerator, PagesGenerator from pelican.tests.support import get_context, get_settings, unittest -try: - from unittest.mock import MagicMock -except ImportError: - try: - from mock import MagicMock - except ImportError: - MagicMock = False CUR_DIR = os.path.dirname(__file__) CONTENT_DIR = os.path.join(CUR_DIR, 'content') @@ -131,7 +125,6 @@ class TestCache(unittest.TestCase): self.assertEqual(uncached_pages, cached_pages) self.assertEqual(uncached_hidden_pages, cached_hidden_pages) - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_article_object_caching(self): """Test Article objects caching at the generator level""" settings = self._get_cache_enabled_settings() @@ -162,7 +155,6 @@ class TestCache(unittest.TestCase): """ self.assertEqual(generator.readers.read_file.call_count, 6) - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_article_reader_content_caching(self): """Test raw article content caching at the reader level""" settings = self._get_cache_enabled_settings() @@ -185,7 +177,6 @@ class TestCache(unittest.TestCase): for reader in readers.values(): self.assertEqual(reader.read.call_count, 0) - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_article_ignore_cache(self): """Test that all the articles are read again when not loading cache @@ -212,7 +203,6 @@ class TestCache(unittest.TestCase): generator.readers.read_file.call_count, orig_call_count) - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_page_object_caching(self): """Test Page objects caching at the generator level""" settings = self._get_cache_enabled_settings() @@ -238,7 +228,6 @@ class TestCache(unittest.TestCase): """ self.assertEqual(generator.readers.read_file.call_count, 1) - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_page_reader_content_caching(self): """Test raw page content caching at the reader level""" settings = self._get_cache_enabled_settings() @@ -262,7 +251,6 @@ class TestCache(unittest.TestCase): for reader in readers.values(): self.assertEqual(reader.read.call_count, 0) - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_page_ignore_cache(self): """Test that all the pages are read again when not loading cache diff --git a/pelican/tests/test_generators.py b/pelican/tests/test_generators.py index 5dd5c3ec..0fd84925 100644 --- a/pelican/tests/test_generators.py +++ b/pelican/tests/test_generators.py @@ -2,6 +2,7 @@ import locale import os from shutil import copy, rmtree from tempfile import mkdtemp +from unittest.mock import MagicMock from pelican.generators import (ArticlesGenerator, Generator, PagesGenerator, PelicanTemplateNotFound, StaticGenerator, @@ -9,14 +10,6 @@ from pelican.generators import (ArticlesGenerator, Generator, PagesGenerator, from pelican.tests.support import get_context, get_settings, unittest from pelican.writers import Writer -try: - from unittest.mock import MagicMock -except ImportError: - try: - from mock import MagicMock - except ImportError: - MagicMock = False - CUR_DIR = os.path.dirname(__file__) CONTENT_DIR = os.path.join(CUR_DIR, 'content') @@ -198,7 +191,6 @@ class TestArticlesGenerator(unittest.TestCase): return [[article.title, article.status, article.category.name, article.template] for article in articles] - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_generate_feeds(self): settings = get_settings() settings['CACHE_PATH'] = self.temp_cache @@ -218,7 +210,6 @@ class TestArticlesGenerator(unittest.TestCase): generator.generate_feeds(writer) self.assertFalse(writer.write_feed.called) - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_generate_feeds_override_url(self): settings = get_settings() settings['CACHE_PATH'] = self.temp_cache @@ -334,7 +325,6 @@ class TestArticlesGenerator(unittest.TestCase): categories_expected = ['default', 'yeah', 'test', 'zhi-dao-shu'] self.assertEqual(sorted(categories), sorted(categories_expected)) - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_direct_templates_save_as_url_default(self): settings = get_settings() @@ -352,7 +342,6 @@ class TestArticlesGenerator(unittest.TestCase): template_name='archives', page_name='archives', url="archives.html") - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_direct_templates_save_as_url_modified(self): settings = get_settings() @@ -373,7 +362,6 @@ class TestArticlesGenerator(unittest.TestCase): page_name='archives/index', url="archives/") - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_direct_templates_save_as_false(self): settings = get_settings() @@ -398,7 +386,6 @@ class TestArticlesGenerator(unittest.TestCase): self.assertIn(custom_template, self.articles) self.assertIn(standard_template, self.articles) - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_period_in_timeperiod_archive(self): """ Test that the context of a generated period_archive is passed @@ -1022,7 +1009,6 @@ class TestStaticGenerator(unittest.TestCase): with open(self.endfile) as f: self.assertEqual(f.read(), "staticcontent") - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_file_update_required_when_dest_does_not_exist(self): staticfile = MagicMock() staticfile.source_path = self.startfile @@ -1032,7 +1018,6 @@ class TestStaticGenerator(unittest.TestCase): update_required = self.generator._file_update_required(staticfile) self.assertTrue(update_required) - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_dest_and_source_mtimes_are_equal(self): staticfile = MagicMock() staticfile.source_path = self.startfile @@ -1045,7 +1030,6 @@ class TestStaticGenerator(unittest.TestCase): isnewer = self.generator._source_is_newer(staticfile) self.assertFalse(isnewer) - @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_source_is_newer(self): staticfile = MagicMock() staticfile.source_path = self.startfile diff --git a/pelican/tests/test_readers.py b/pelican/tests/test_readers.py index eb755338..de2a1b22 100644 --- a/pelican/tests/test_readers.py +++ b/pelican/tests/test_readers.py @@ -1,16 +1,10 @@ import os +from unittest.mock import patch from pelican import readers from pelican.tests.support import get_settings, unittest from pelican.utils import SafeDatetime -try: - from unittest.mock import patch -except ImportError: - try: - from mock import patch - except ImportError: - patch = False CUR_DIR = os.path.dirname(__file__) CONTENT_PATH = os.path.join(CUR_DIR, 'content') @@ -125,7 +119,6 @@ class DefaultReaderTest(ReaderTest): self.assertDictHasSubset(page.metadata, expected) - @unittest.skipUnless(patch, 'Needs Mock module') def test_find_empty_alt(self): with patch('pelican.readers.logger') as log_mock: content = ['', diff --git a/pelican/tests/test_rstdirectives.py b/pelican/tests/test_rstdirectives.py index 36623fc4..6b733971 100644 --- a/pelican/tests/test_rstdirectives.py +++ b/pelican/tests/test_rstdirectives.py @@ -1,15 +1,8 @@ +from unittest.mock import Mock + from pelican.tests.support import unittest -try: - from unittest.mock import Mock -except ImportError: - try: - from mock import Mock - except ImportError: - Mock = False - -@unittest.skipUnless(Mock, 'Needs Mock module') class Test_abbr_role(unittest.TestCase): def call_it(self, text): from pelican.rstdirectives import abbr_role diff --git a/requirements/docs.pip b/requirements/docs.pip index acc5d5f5..bd25c939 100644 --- a/requirements/docs.pip +++ b/requirements/docs.pip @@ -1,3 +1,3 @@ -sphinx==1.4.9 +sphinx sphinx_rtd_theme livereload diff --git a/requirements/test.pip b/requirements/test.pip index 81d74c4e..973b27ca 100644 --- a/requirements/test.pip +++ b/requirements/test.pip @@ -1,6 +1,5 @@ # Tests Pygments==2.6.1 -mock pytest==5.3.5 pytest-cov pytest-xdist diff --git a/tasks.py b/tasks.py index 495194ab..52bfe6a3 100644 --- a/tasks.py +++ b/tasks.py @@ -24,7 +24,7 @@ PRECOMMIT = ( @task def docbuild(c): """Build documentation""" - c.run(f"{VENV_BIN}/sphinx-build docs docs/_build") + c.run(f"{VENV_BIN}/sphinx-build -W docs docs/_build") @task(docbuild) diff --git a/tox.ini b/tox.ini index 6cc34498..18b0e7a4 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ deps = commands = {envpython} --version - pytest -sv --cov=pelican pelican + pytest -s --cov=pelican pelican [testenv:docs] basepython = python3.6 @@ -28,7 +28,7 @@ commands = filterwarnings = default::DeprecationWarning error:.*:Warning:pelican -addopts = -n 2 +addopts = -n 2 -r a [flake8] application-import-names = pelican