Fix extension of of cached re-written file
With PYTHONOPTIMIZE set this had the extension of "o" instead of ".pyo". Fixes issue #168.
This commit is contained in:
parent
fe24e01a03
commit
1aca6c9d7c
|
@ -34,7 +34,7 @@ else:
|
||||||
PYTEST_TAG = "%s-%s%s-PYTEST" % (impl, ver[0], ver[1])
|
PYTEST_TAG = "%s-%s%s-PYTEST" % (impl, ver[0], ver[1])
|
||||||
del ver, impl
|
del ver, impl
|
||||||
|
|
||||||
PYC_EXT = ".py" + "c" if __debug__ else "o"
|
PYC_EXT = ".py" + ("c" if __debug__ else "o")
|
||||||
PYC_TAIL = "." + PYTEST_TAG + PYC_EXT
|
PYC_TAIL = "." + PYTEST_TAG + PYC_EXT
|
||||||
|
|
||||||
REWRITE_NEWLINES = sys.version_info[:2] != (2, 7) and sys.version_info < (3, 2)
|
REWRITE_NEWLINES = sys.version_info[:2] != (2, 7) and sys.version_info < (3, 2)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import zipfile
|
import zipfile
|
||||||
import py
|
import py
|
||||||
|
@ -352,6 +353,7 @@ 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):
|
||||||
|
import _pytest.assertion.rewrite
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
def test_optimized():
|
def test_optimized():
|
||||||
|
@ -362,8 +364,12 @@ def test_optimized():
|
||||||
tmp = "--basetemp=%s" % p
|
tmp = "--basetemp=%s" % p
|
||||||
monkeypatch.setenv("PYTHONOPTIMIZE", "2")
|
monkeypatch.setenv("PYTHONOPTIMIZE", "2")
|
||||||
assert testdir.runpybin("py.test", tmp).ret == 0
|
assert testdir.runpybin("py.test", tmp).ret == 0
|
||||||
|
fname = 'test_pyc_vs_pyo.%s.pyo' % _pytest.assertion.rewrite.PYTEST_TAG
|
||||||
|
assert fname in os.listdir('__pycache__')
|
||||||
monkeypatch.undo()
|
monkeypatch.undo()
|
||||||
assert testdir.runpybin("py.test", tmp).ret == 1
|
assert testdir.runpybin("py.test", tmp).ret == 1
|
||||||
|
fname = 'test_pyc_vs_pyo.%s.pyc' % _pytest.assertion.rewrite.PYTEST_TAG
|
||||||
|
assert fname in os.listdir('__pycache__')
|
||||||
|
|
||||||
def test_package(self, testdir):
|
def test_package(self, testdir):
|
||||||
pkg = testdir.tmpdir.join("pkg")
|
pkg = testdir.tmpdir.join("pkg")
|
||||||
|
|
Loading…
Reference in New Issue