fix issue206 - unset PYTHONDONTWRITEBYTECODE in assertrewrite test

This commit is contained in:
holger krekel 2012-10-22 11:14:18 +02:00
parent 1b61fbc8ed
commit 036557ac18
5 changed files with 24 additions and 8 deletions

View File

@ -6,6 +6,9 @@ Changes between 2.3.1 and 2.3.2.dev
- fix exception message check of test_nose.py to pass on python33 as well - fix exception message check of test_nose.py to pass on python33 as well
- fix issue206 - fix test_assertrewrite.py to work when a global
PYTHONDONTWRITEBYTECODE=1 is present
- add tox.ini to pytest distribution so that ignore-dirs and others config - add tox.ini to pytest distribution so that ignore-dirs and others config
bits are properly distributed for maintainers who run pytest-own tests bits are properly distributed for maintainers who run pytest-own tests

View File

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

View File

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

View File

@ -354,18 +354,21 @@ def test_no_bytecode():
@pytest.mark.skipif('"__pypy__" in sys.modules') @pytest.mark.skipif('"__pypy__" in sys.modules')
def test_pyc_vs_pyo(self, testdir, monkeypatch): def test_pyc_vs_pyo(self, testdir, monkeypatch):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
def test_optimized(): def test_optimized():
"hello" "hello"
assert test_optimized.__doc__ is None""") assert test_optimized.__doc__ is None"""
)
p = py.path.local.make_numbered_dir(prefix="runpytest-", keep=None, p = py.path.local.make_numbered_dir(prefix="runpytest-", keep=None,
rootdir=testdir.tmpdir) rootdir=testdir.tmpdir)
tmp = "--basetemp=%s" % p tmp = "--basetemp=%s" % p
monkeypatch.setenv("PYTHONOPTIMIZE", "2") monkeypatch.setenv("PYTHONOPTIMIZE", "2")
monkeypatch.delenv("PYTHONDONTWRITEBYTECODE", raising=False)
assert testdir.runpybin("py.test", tmp).ret == 0 assert testdir.runpybin("py.test", tmp).ret == 0
tagged = "test_pyc_vs_pyo." + PYTEST_TAG tagged = "test_pyc_vs_pyo." + PYTEST_TAG
assert tagged + ".pyo" in os.listdir("__pycache__") assert tagged + ".pyo" in os.listdir("__pycache__")
monkeypatch.undo() monkeypatch.undo()
monkeypatch.delenv("PYTHONDONTWRITEBYTECODE", raising=False)
assert testdir.runpybin("py.test", tmp).ret == 1 assert testdir.runpybin("py.test", tmp).ret == 1
assert tagged + ".pyc" in os.listdir("__pycache__") assert tagged + ".pyc" in os.listdir("__pycache__")

14
tox.ini
View File

@ -1,6 +1,6 @@
[tox] [tox]
distshare={homedir}/.tox/distshare distshare={homedir}/.tox/distshare
envlist=py26,py27,py31,py32,py33,py27-xdist,py25,trial envlist=py26,py27,py27-nobyte,py31,py32,py33,py27-xdist,py25,trial
indexserver= indexserver=
pypi = http://pypi.python.org/simple pypi = http://pypi.python.org/simple
testrun = http://pypi.testrun.org testrun = http://pypi.testrun.org
@ -24,7 +24,17 @@ basepython=python2.7
deps=pytest-xdist deps=pytest-xdist
commands= commands=
py.test -n3 -rfsxX \ py.test -n3 -rfsxX \
--ignore .tox --junitxml={envlogdir}/junit-{envname}.xml testing --junitxml={envlogdir}/junit-{envname}.xml testing
[testenv:py27-nobyte]
changedir=.
basepython=python2.7
deps=pytest-xdist
setenv=
PYTHONDONTWRITEBYTECODE=1
commands=
py.test -n3 -rfsxX \
--junitxml={envlogdir}/junit-{envname}.xml []
[testenv:trial] [testenv:trial]
changedir=. changedir=.