diff --git a/CHANGELOG b/CHANGELOG index e20f30dd3..207aa899e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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. diff --git a/_pytest/__init__.py b/_pytest/__init__.py index 596e2bcdf..7f1034c8e 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.1.0.dev4' +__version__ = '2.1.0.dev5' diff --git a/_pytest/assertion/__init__.py b/_pytest/assertion/__init__.py index 33823b877..fec80a1bd 100644 --- a/_pytest/assertion/__init__.py +++ b/_pytest/assertion/__init__.py @@ -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): diff --git a/setup.py b/setup.py index c93e2d922..084bb498f 100644 --- a/setup.py +++ b/setup.py @@ -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'], diff --git a/testing/test_assertion.py b/testing/test_assertion.py index 0a727ce62..a00b430fd 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -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():