diff --git a/tests/__init__.py b/tests/__init__.py index 7679ddc..14e6b78 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -26,6 +26,12 @@ class BaseTestCase(unittest.TestCase): except OSError: pass + def extend_config(self, *args): + base_config = self.BASE_VALID_CONFIG.copy() + for arg in args: + base_config = dict(base_config, **arg) + return base_config + def delete_templates(self): for template in [ 'header.html', diff --git a/tests/test_context.py b/tests/test_context.py index 4a1722c..b5eb9ad 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -30,7 +30,7 @@ class ContextTestCase(BaseTestCase): self.assertIn(key, context) def test_context_contains_context(self): - config = dict(self.BASE_VALID_CONFIG, **{ + config = self.extend_config({ 'context': { '1': '2' } @@ -49,7 +49,7 @@ class ContextTestCase(BaseTestCase): self.assertEqual(context['output_dir'], os.path.abspath(self.BASE_VALID_CONFIG['output_dir'])) def test_word_count(self): - config = dict(self.BASE_VALID_CONFIG, **{ + config = self.extend_config({ 'show_word_count': True }) context = get_context(config, 'testy test test') @@ -61,14 +61,14 @@ class ContextTestCase(BaseTestCase): datetime.now().time(), datetime.now() ]: - config = dict(self.BASE_VALID_CONFIG, **{ + config = self.extend_config({ 'submission_date': value }) context = get_context(config, 'test') self.assertEqual(context['submission_date'], value.strftime(consts.DATE_FORMAT)) def test_date_format(self): - config = dict(self.BASE_VALID_CONFIG, **{ + config = self.extend_config({ 'submission_date': '2017-01-01' }) context = get_context(config, 'test') diff --git a/tests/test_parser.py b/tests/test_parser.py index 6182204..ec28f5f 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -44,14 +44,14 @@ class AddBodyClassTestCase(BaseTestCase): class RenderTemplateTestCase(BaseTestCase): def test_renders_template(self): html = 'test {{ test }}' - output = content.render_template(html, dict(self.BASE_VALID_CONFIG, **{ + output = content.render_template(html, self.extend_config({ 'test': 'content' })) self.assertEqual(output, 'test content') def test_changes_nothing(self): html = 'test test' - output = content.render_template(html, dict(self.BASE_VALID_CONFIG, **{ + output = content.render_template(html, self.extend_config({ 'test': 'content' })) self.assertEqual(output, html)