diff --git a/tests/check_astunparse.py b/tests/check_astunparse.py index 65c590c..8950ee8 100644 --- a/tests/check_astunparse.py +++ b/tests/check_astunparse.py @@ -1,9 +1,6 @@ import ast -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from . import test_code_gen diff --git a/tests/test_code_gen.py b/tests/test_code_gen.py index 66e1014..0461b90 100644 --- a/tests/test_code_gen.py +++ b/tests/test_code_gen.py @@ -12,11 +12,7 @@ import math import sys import textwrap - -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import astor diff --git a/tests/test_misc.py b/tests/test_misc.py index d81b635..4fe4013 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -1,10 +1,7 @@ import ast import sys +import unittest import warnings -try: - import unittest2 as unittest -except ImportError: - import unittest import astor diff --git a/tests/test_optional.py b/tests/test_optional.py index 894fa6d..09c54e4 100644 --- a/tests/test_optional.py +++ b/tests/test_optional.py @@ -10,31 +10,25 @@ """ -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest -try: - from test_code_gen import Comparisons -except ImportError: - from .test_code_gen import Comparisons +from .test_code_gen import Comparisons try: from astunparse_common import AstunparseCommonTestCase except ImportError: - AstunparseCommonTestCase = None + AstunparseCommonTestCase = object + + +@unittest.skipIf(AstunparseCommonTestCase is object, "requires astunparse") +class UnparseTestCase(unittest.TestCase, Comparisons, AstunparseCommonTestCase): -if AstunparseCommonTestCase is not None: + def check_roundtrip(self, code1, mode=None): + self.assertAstRoundtrips(code1) - class UnparseTestCase(AstunparseCommonTestCase, unittest.TestCase, - Comparisons): - - def check_roundtrip(self, code1, mode=None): - self.assertAstRoundtrips(code1) + def test_files(self): + """ Don't bother -- we do this manually and more thoroughly """ - def test_files(self): - """ Don't bother -- we do this manually and more thoroughly """ if __name__ == '__main__': unittest.main() diff --git a/tests/test_rtrip.py b/tests/test_rtrip.py index 8abd951..c71fcc4 100644 --- a/tests/test_rtrip.py +++ b/tests/test_rtrip.py @@ -7,11 +7,7 @@ """ import os - -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import astor.rtrip