summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Jehannet <julien.jehannet@logilab.fr>2010-11-17 19:22:52 +0100
committerJulien Jehannet <julien.jehannet@logilab.fr>2010-11-17 19:22:52 +0100
commitb533d48c3d606549772aeb9bc7697e13974ef023 (patch)
treef1a96134dd7f9409f3f0d0adbbc811ed52a76e46
parentcb7f88527dc1ed478b45e52307e0b83718cfcb5d (diff)
downloadlogilab-common-b533d48c3d606549772aeb9bc7697e13974ef023.tar.gz
pytest: make test suite compatible with 2.7
-rw-r--r--pytest.py5
-rw-r--r--testlib.py5
2 files changed, 6 insertions, 4 deletions
diff --git a/pytest.py b/pytest.py
index d2ec378..da007c0 100644
--- a/pytest.py
+++ b/pytest.py
@@ -118,11 +118,12 @@ import types
from logilab.common.fileutils import abspath_listdir
from logilab.common import testlib, STD_BLACKLIST
+# use the same unittest module as testlib
from logilab.common.testlib import unittest
import doctest
-# use the same unittest module as testlib
-if sys.version_info < (3, 2):
+import unittest as unittest_legacy
+if not getattr(unittest_legacy, "__package__", None):
try:
import unittest2.suite as unittest_suite
except ImportError:
diff --git a/testlib.py b/testlib.py
index 49304e3..ed18cff 100644
--- a/testlib.py
+++ b/testlib.py
@@ -57,7 +57,8 @@ from ConfigParser import ConfigParser
from logilab.common.deprecation import deprecated
from itertools import dropwhile
-if sys.version_info < (3, 2):
+import unittest as unittest_legacy
+if not getattr(unittest_legacy, "__package__", None):
try:
import unittest2 as unittest
from unittest2 import SkipTest
@@ -969,7 +970,7 @@ succeeded test into", osp.join(os.getcwd(), FILE_RESTART)
from xml.parsers.expat import ExpatError
try:
parse(data)
- except ExpatError, ex:
+ except (ExpatError, ParseError), ex:
if msg is None:
if hasattr(data, 'readlines'): #file like object
data.seek(0)