summaryrefslogtreecommitdiff
path: root/pyflakes/test/harness.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2013-07-02 17:47:53 +0200
committerFlorent Xicluna <florent.xicluna@gmail.com>2013-07-02 17:47:53 +0200
commit2360e1df01a0ff579260b6430862a9aa2c58c618 (patch)
tree249e4c716c48d05d84a56b64e449f83a2e55e59c /pyflakes/test/harness.py
parent0847a55e3bb19a3935ca2e36d36f1a97b85e0cc8 (diff)
downloadpyflakes-2360e1df01a0ff579260b6430862a9aa2c58c618.tar.gz
Remove dependency on unittest2 completely
Diffstat (limited to 'pyflakes/test/harness.py')
-rw-r--r--pyflakes/test/harness.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/pyflakes/test/harness.py b/pyflakes/test/harness.py
index 7d1b5db..9f337e5 100644
--- a/pyflakes/test/harness.py
+++ b/pyflakes/test/harness.py
@@ -1,18 +1,26 @@
+import sys
import textwrap
-import _ast
-
import unittest
from pyflakes import checker
+__all__ = ['TestCase', 'skip', 'skipIf']
+
+if sys.version_info < (2, 7):
+ skip = lambda why: (lambda func: 'skip') # not callable
+ skipIf = lambda cond, why: (skip(why) if cond else lambda func: func)
+else:
+ skip = unittest.skip
+ skipIf = unittest.skipIf
+PyCF_ONLY_AST = 1024
+
-class Test(unittest.TestCase):
+class TestCase(unittest.TestCase):
def flakes(self, input, *expectedOutputs, **kw):
- ast = compile(textwrap.dedent(input), "<test>", "exec",
- _ast.PyCF_ONLY_AST)
- w = checker.Checker(ast, **kw)
+ tree = compile(textwrap.dedent(input), "<test>", "exec", PyCF_ONLY_AST)
+ w = checker.Checker(tree, **kw)
outputs = [type(o) for o in w.messages]
expectedOutputs = list(expectedOutputs)
outputs.sort(key=lambda t: t.__name__)
@@ -21,7 +29,13 @@ class Test(unittest.TestCase):
for input:
%s
expected outputs:
-%s
+%r
but got:
-%s''' % (input, repr(expectedOutputs), '\n'.join([str(o) for o in w.messages])))
+%s''' % (input, expectedOutputs, '\n'.join([str(o) for o in w.messages])))
return w
+
+ if sys.version_info < (2, 7):
+
+ def assertIs(self, expr1, expr2, msg=None):
+ if expr1 is not expr2:
+ self.fail(msg or '%r is not %r' % (expr1, expr2))