summaryrefslogtreecommitdiff
path: root/simple_unit_tests.py
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@austin.rr.com>2019-08-10 23:31:29 -0500
committerPaul McGuire <ptmcg@austin.rr.com>2019-08-10 23:31:29 -0500
commit781a39cbc43525b8d8d36baec30438027fbc14e0 (patch)
tree947f97f1143a6694eb9574bbb815426bd13e5d6b /simple_unit_tests.py
parent675e87a859ce9f7bfefb091e9d6198c4a7f5eafd (diff)
downloadpyparsing-git-781a39cbc43525b8d8d36baec30438027fbc14e0.tar.gz
Remove Py2 compatibility code from unit tests
Diffstat (limited to 'simple_unit_tests.py')
-rw-r--r--simple_unit_tests.py25
1 files changed, 1 insertions, 24 deletions
diff --git a/simple_unit_tests.py b/simple_unit_tests.py
index 1af7474..6fdab44 100644
--- a/simple_unit_tests.py
+++ b/simple_unit_tests.py
@@ -7,12 +7,7 @@
#
# Copyright (c) 2018 Paul T. McGuire
#
-from __future__ import division
-
-try:
- import unittest2 as unittest
-except ImportError:
- import unittest
+import unittest
import pyparsing as pp
from collections import namedtuple
from datetime import datetime
@@ -29,15 +24,6 @@ class PyparsingExpressionTestCase(unittest.TestCase):
given text strings. Subclasses must define a class attribute 'tests' which
is a list of PpTestSpec instances.
"""
-
- if not hasattr(unittest.TestCase, 'subTest'):
- # Python 2 compatibility
- from contextlib import contextmanager
- @contextmanager
- def subTest(self, **params):
- print('subTest:', params)
- yield
-
tests = []
def runTest(self):
if self.__class__ is PyparsingExpressionTestCase:
@@ -83,11 +69,6 @@ class PyparsingExpressionTestCase(unittest.TestCase):
try:
parsefn(test_spec.text)
except Exception as exc:
- if not hasattr(exc, '__traceback__'):
- # Python 2 compatibility
- from sys import exc_info
- etype, value, traceback = exc_info()
- exc.__traceback__ = traceback
print(pp.ParseException.explain(exc))
self.assertEqual(exc.loc, test_spec.expected_fail_locn)
else:
@@ -474,10 +455,6 @@ suite = unittest.TestSuite(cls() for cls in test_case_classes)
# ============ MAIN ================
if __name__ == '__main__':
- import sys
- if sys.version_info[0] < 3:
- print("simple_unit_tests.py requires Python 3.x - exiting...")
- exit(0)
result = unittest.TextTestRunner().run(suite)