mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Remove duplicate tests in test_contents
TestArticle was a subclass of TestPage and therefore included all the tests TestPage already had. Effectively tests from TestPage were run twice. This splits the common parts of TestPage to a base class called TestBase and TestPage/TestArticle will both inherit from it.
This commit is contained in:
parent
021ef45f75
commit
82fcfbcbfc
1 changed files with 16 additions and 14 deletions
|
|
@ -22,7 +22,7 @@ TEST_CONTENT = str(generate_lorem_ipsum(n=1))
|
||||||
TEST_SUMMARY = generate_lorem_ipsum(n=1, html=False)
|
TEST_SUMMARY = generate_lorem_ipsum(n=1, html=False)
|
||||||
|
|
||||||
|
|
||||||
class TestPage(LoggedTestCase):
|
class TestBase(LoggedTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
@ -54,6 +54,20 @@ class TestPage(LoggedTestCase):
|
||||||
from pelican.contents import logger
|
from pelican.contents import logger
|
||||||
logger.enable_filter()
|
logger.enable_filter()
|
||||||
|
|
||||||
|
def _copy_page_kwargs(self):
|
||||||
|
# make a deep copy of page_kwargs
|
||||||
|
page_kwargs = dict([(key, self.page_kwargs[key]) for key in
|
||||||
|
self.page_kwargs])
|
||||||
|
for key in page_kwargs:
|
||||||
|
if not isinstance(page_kwargs[key], dict):
|
||||||
|
break
|
||||||
|
page_kwargs[key] = dict([(subkey, page_kwargs[key][subkey])
|
||||||
|
for subkey in page_kwargs[key]])
|
||||||
|
|
||||||
|
return page_kwargs
|
||||||
|
|
||||||
|
|
||||||
|
class TestPage(TestBase):
|
||||||
def test_use_args(self):
|
def test_use_args(self):
|
||||||
# Creating a page with arguments passed to the constructor should use
|
# Creating a page with arguments passed to the constructor should use
|
||||||
# them to initialise object's attributes.
|
# them to initialise object's attributes.
|
||||||
|
|
@ -268,18 +282,6 @@ class TestPage(LoggedTestCase):
|
||||||
custom_page = Page(**page_kwargs)
|
custom_page = Page(**page_kwargs)
|
||||||
self.assertEqual('custom', custom_page.template)
|
self.assertEqual('custom', custom_page.template)
|
||||||
|
|
||||||
def _copy_page_kwargs(self):
|
|
||||||
# make a deep copy of page_kwargs
|
|
||||||
page_kwargs = dict([(key, self.page_kwargs[key]) for key in
|
|
||||||
self.page_kwargs])
|
|
||||||
for key in page_kwargs:
|
|
||||||
if not isinstance(page_kwargs[key], dict):
|
|
||||||
break
|
|
||||||
page_kwargs[key] = dict([(subkey, page_kwargs[key][subkey])
|
|
||||||
for subkey in page_kwargs[key]])
|
|
||||||
|
|
||||||
return page_kwargs
|
|
||||||
|
|
||||||
def test_signal(self):
|
def test_signal(self):
|
||||||
def receiver_test_function(sender):
|
def receiver_test_function(sender):
|
||||||
receiver_test_function.has_been_called = True
|
receiver_test_function.has_been_called = True
|
||||||
|
|
@ -602,7 +604,7 @@ class TestPage(LoggedTestCase):
|
||||||
assert content.author == content.authors[0]
|
assert content.author == content.authors[0]
|
||||||
|
|
||||||
|
|
||||||
class TestArticle(TestPage):
|
class TestArticle(TestBase):
|
||||||
def test_template(self):
|
def test_template(self):
|
||||||
# Articles default to article, metadata overwrites
|
# Articles default to article, metadata overwrites
|
||||||
default_article = Article(**self.page_kwargs)
|
default_article = Article(**self.page_kwargs)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue