fix python2.5 compatibility

This commit is contained in:
holger krekel 2011-07-05 15:21:08 +02:00
parent a4fe63c08d
commit 407ca5b120
5 changed files with 9 additions and 6 deletions

View File

@ -1,6 +1,7 @@
Changes between 2.0.3 and 2.1.0.DEV
----------------------------------------------
- fix issue58 and issue59: new assertion code fixes
- merge Benjamin's assertionrewrite branch: now assertions
for test modules on python 2.6 and above are done by rewriting
the AST and saving the pyc file before the test module is imported.

View File

@ -1,2 +1,2 @@
#
__version__ = '2.1.0.dev4'
__version__ = '2.1.0.dev5'

View File

@ -7,8 +7,6 @@ import pytest
from _pytest.monkeypatch import monkeypatch
from _pytest.assertion import util
REWRITING_AVAILABLE = "_ast" in sys.builtin_module_names
def pytest_addoption(parser):
group = parser.getgroup("debugconfig")
group.addoption('--assertmode', action="store", dest="assertmode",
@ -40,8 +38,11 @@ def pytest_configure(config):
mode = "off"
elif mode == "default":
mode = "rewrite"
if mode == "on" and not REWRITING_AVAILABLE:
mode = "reinterp"
if mode == "rewrite":
try:
import ast
except ImportError:
mode = "reinterp"
if mode != "off":
_load_modules(mode)
def callbinrepr(op, left, right):

View File

@ -22,7 +22,7 @@ def main():
name='pytest',
description='py.test: simple powerful testing with Python',
long_description = long_description,
version='2.1.0.dev4',
version='2.1.0.dev5',
url='http://pytest.org',
license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],

View File

@ -120,6 +120,7 @@ class TestAssert_reprcompare:
expl = ' '.join(callequal('foo', 'bar'))
assert 'raised in repr()' not in expl
@needsnewassert
def test_rewritten(testdir):
testdir.makepyfile("""
def test_rewritten():