Permalink
Browse files

Fix error with unspecified option, update tests.

  • Loading branch information...
1 parent e214fbc commit 9f37d90187ac8b7010c8e1944604a8c5af4ab590 @tkaemming tkaemming committed Oct 24, 2012
Showing with 21 additions and 12 deletions.
  1. +1 −1 VERSION
  2. +4 −1 templateusage/plugin.py
  3. +16 −10 tests/tests.py
View
@@ -1 +1 @@
-0.1.3
+0.1.4
View
@@ -44,10 +44,13 @@ def options(self, parser, env):
action='store_true', help='Enable template usage reporting.')
parser.add_option("--ignore-template-prefix", dest='ignore_prefixes',
- action='append', help='Add a template directory to the ignore list.')
+ action='append', help='Add a template directory to the ignore list.',
+ default=[])
def configure(self, options, conf):
self.enabled = options.enabled
+ if not self.enabled:
+ return
ignore_prefixes = options.ignore_prefixes
# Allow for multiple values in a single argument, e.g. from `setup.cfg`.
View
@@ -30,13 +30,20 @@
from templateusage import TemplateUsageReportPlugin
-class TestPluginFoo(PluginTester, unittest.TestCase):
+class TemplateUsageReportTestMixin(PluginTester):
+ TEMPLATE_NAME = 'example.html'
+
activate = '--with-template-usage-report'
- args = ('--ignore-template-prefix=ignored/',)
plugins = [TemplateUsageReportPlugin()]
- TEMPLATE_NAME = 'example.html'
+ def makeSuite(self):
+ class TestCase(unittest.TestCase):
+ def runTest(_self):
+ get_template(self.TEMPLATE_NAME)
+ return unittest.TestSuite([TestCase()])
+
+class TemplateUsageReportPluginTestCase(TemplateUsageReportTestMixin, unittest.TestCase):
def test_basic(self):
self.assertIn(self.TEMPLATE_NAME, self.plugins[0].used_templates)
@@ -46,11 +53,10 @@ def test_included(self):
def test_unused(self):
self.assertIn('unused.html', self.plugins[0].unused_templates)
- def test_ignored(self):
- self.assertNotIn('ignored.html', self.plugins[0].unused_templates)
- def makeSuite(self):
- class TestCase(unittest.TestCase):
- def runTest(_self):
- get_template(self.TEMPLATE_NAME)
- return unittest.TestSuite([TestCase()])
+class IgnoredDirectoryUsageReportPluginTestCase(TemplateUsageReportTestMixin, unittest.TestCase):
+ args = ('--ignore-template-prefix=ignored/',)
+
+ def test_ignored(self):
+ self.assertNotIn('ignored/ignored.html', self.plugins[0].used_templates)
+ self.assertNotIn('ignored/ignored.html', self.plugins[0].unused_templates)

0 comments on commit 9f37d90

Please sign in to comment.