From 3306968f415a0a40482be2e5a5df867fd1de8aee Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Mon, 4 Apr 2016 15:38:15 +1200 Subject: [PATCH] Cleanup tests: - always use unittest2 - remove unneeded boilerplate - disable pypy3 in travis, as its currently broken --- .gitignore | 1 + .travis.yml | 2 +- README.rst | 2 +- tests/test_formatannotation.py | 12 +----------- tests/test_funcsigs.py | 4 ---- tests/test_inspect.py | 29 +---------------------------- 6 files changed, 5 insertions(+), 45 deletions(-) diff --git a/.gitignore b/.gitignore index 13dbbcf..c8d2af8 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ htmlcov/ tmp/ coverage.xml junit.xml +.eggs/ diff --git a/.travis.yml b/.travis.yml index 63d02d1..c1e7abe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ python: - 3.5 - nightly - pypy - - pypy3 +# - pypy3 install: - pip install -U pip setuptools wheel - pip install -r requirements/development.txt . diff --git a/README.rst b/README.rst index a6a57bf..5fbca27 100644 --- a/README.rst +++ b/README.rst @@ -26,7 +26,7 @@ The ``funcsigs`` backport has been tested against: * CPython 3.4 * CPython 3.5 * CPython nightlies -* PyPy and PyPy3 +* PyPy and PyPy3(currently failing CI) Continuous integration testing is provided by `Travis CI`_. diff --git a/tests/test_formatannotation.py b/tests/test_formatannotation.py index fd7a887..4b98e60 100644 --- a/tests/test_formatannotation.py +++ b/tests/test_formatannotation.py @@ -1,12 +1,6 @@ -try: - # python 2.x - import unittest2 as unittest -except ImportError: - # python 3.x - import unittest - import funcsigs +import unittest2 as unittest class TestFormatAnnotation(unittest.TestCase): def test_string (self): @@ -21,7 +15,3 @@ class TestFormatAnnotation(unittest.TestCase): class dummy (object): pass self.assertEqual(funcsigs.formatannotation(dummy), "tests.test_formatannotation.dummy") - - -if __name__ == "__main__": - unittest.begin() diff --git a/tests/test_funcsigs.py b/tests/test_funcsigs.py index b4e550a..ead2863 100644 --- a/tests/test_funcsigs.py +++ b/tests/test_funcsigs.py @@ -85,7 +85,3 @@ class TestFunctionSignatures(unittest.TestCase): ('self', Ellipsis, Ellipsis, self_kind), ('a', Ellipsis, Ellipsis, "positional_or_keyword"), ), Ellipsis)) - - -if __name__ == "__main__": - unittest.begin() diff --git a/tests/test_inspect.py b/tests/test_inspect.py index c6dc03d..98d6592 100644 --- a/tests/test_inspect.py +++ b/tests/test_inspect.py @@ -4,10 +4,7 @@ import collections import functools import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest2 as unittest import funcsigs as inspect @@ -25,11 +22,6 @@ class TestSignatureObject(unittest.TestCase): (Ellipsis if sig.return_annotation is sig.empty else sig.return_annotation)) - def __init__(self, *args, **kwargs): - unittest.TestCase.__init__(self, *args, **kwargs) - if not hasattr(self, 'assertRaisesRegex'): - self.assertRaisesRegex = self.assertRaisesRegexp - if sys.version_info[0] > 2: exec(""" def test_signature_object(self): @@ -657,11 +649,6 @@ def test_signature_replace_anno(self): class TestParameterObject(unittest.TestCase): - def __init__(self, *args, **kwargs): - unittest.TestCase.__init__(self, *args, **kwargs) - if not hasattr(self, 'assertRaisesRegex'): - self.assertRaisesRegex = self.assertRaisesRegexp - def test_signature_parameter_kinds(self): P = inspect.Parameter self.assertTrue(P.POSITIONAL_ONLY < P.POSITIONAL_OR_KEYWORD < \ @@ -781,11 +768,6 @@ class TestSignatureBind(unittest.TestCase): ba = sig.bind(*args, **kwargs) return func(*ba.args, **ba.kwargs) - def __init__(self, *args, **kwargs): - unittest.TestCase.__init__(self, *args, **kwargs) - if not hasattr(self, 'assertRaisesRegex'): - self.assertRaisesRegex = self.assertRaisesRegexp - def test_signature_bind_empty(self): def test(): return 42 @@ -995,11 +977,6 @@ def test_signature_bind_positional_only(self): class TestBoundArguments(unittest.TestCase): - def __init__(self, *args, **kwargs): - unittest.TestCase.__init__(self, *args, **kwargs) - if not hasattr(self, 'assertRaisesRegex'): - self.assertRaisesRegex = self.assertRaisesRegexp - def test_signature_bound_arguments_unhashable(self): def foo(a): pass ba = inspect.signature(foo).bind(1) @@ -1023,7 +1000,3 @@ class TestBoundArguments(unittest.TestCase): def bar(b): pass ba4 = inspect.signature(bar).bind(1) self.assertNotEqual(ba, ba4) - - -if __name__ == "__main__": - unittest.begin()