forked from github/pelican
Cleanup test environment and requirements
- pytest: verbose isn't needed but show skipped tests - mock is not needed anymore. it is part of stdlib - Unpin Sphinx and fix warning about lexer - Mirror tox command for doc build in tasks.py
This commit is contained in:
parent
125dec493e
commit
839629b102
10 changed files with 11 additions and 54 deletions
|
|
@ -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 -------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 = ['<img alt="" src="test-image.png" width="300px" />',
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
sphinx==1.4.9
|
||||
sphinx
|
||||
sphinx_rtd_theme
|
||||
livereload
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# Tests
|
||||
Pygments==2.6.1
|
||||
mock
|
||||
pytest==5.3.5
|
||||
pytest-cov
|
||||
pytest-xdist
|
||||
|
|
|
|||
2
tasks.py
2
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)
|
||||
|
|
|
|||
4
tox.ini
4
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue