summaryrefslogtreecommitdiff
path: root/testutils.py
diff options
context:
space:
mode:
authorTorsten Marek <shlomme@gmail.com>2014-03-30 14:19:33 -0700
committerTorsten Marek <shlomme@gmail.com>2014-03-30 14:19:33 -0700
commita71ce3ab777233e2ba97112f62226c50e4e90724 (patch)
tree427fed04bbcdce3cc4e6ac87a32167c7290d8196 /testutils.py
parent506b047a4ef042c1b128b59ef5dd29f5da4a90f1 (diff)
downloadpylint-git-a71ce3ab777233e2ba97112f62226c50e4e90724.tar.gz
Add a new decorator that can be used to declaratively set options on the checker instance for CheckerTestCase.
Diffstat (limited to 'testutils.py')
-rw-r--r--testutils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/testutils.py b/testutils.py
index 818a5769f..668bd6d28 100644
--- a/testutils.py
+++ b/testutils.py
@@ -18,6 +18,7 @@ from __future__ import with_statement
import collections
import contextlib
+import functools
import sys
import re
@@ -149,6 +150,19 @@ class UnittestLinter(object):
self.stats[name] = value
+def set_config(**kwargs):
+ """Decorator for setting config values on a checker."""
+ def _Wrapper(fun):
+ functools.wraps(fun)
+ def _Forward(self):
+ for key, value in kwargs.iteritems():
+ setattr(self.checker.config, key, value)
+ fun(self)
+
+ return _Forward
+ return _Wrapper
+
+
class CheckerTestCase(testlib.TestCase):
"""A base testcase class for unittesting individual checker classes."""
CHECKER_CLASS = None