[py-svn] commit/pytest: flub: Fix extension of of cached re-written file

Bitbucket commits-noreply at bitbucket.org
Sat Jul 7 16:10:15 CEST 2012


1 new commit in pytest:


https://bitbucket.org/hpk42/pytest/changeset/1e9f8d37d4bf/
changeset:   1e9f8d37d4bf
user:        flub
date:        2012-07-07 16:09:53
summary:     Fix extension of of cached re-written file

With PYTHONOPTIMIZE set this had the extension of "o" instead of ".pyo".
Fixes issue #168.
affected #:  2 files

diff -r d50ce2daf212727b324e43b26b838e78612102ed -r 1e9f8d37d4bf6f51aa651546ed37c5579a30fec7 _pytest/assertion/rewrite.py
--- a/_pytest/assertion/rewrite.py
+++ b/_pytest/assertion/rewrite.py
@@ -34,7 +34,7 @@
     PYTEST_TAG = "%s-%s%s-PYTEST" % (impl, ver[0], ver[1])
     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
 
 REWRITE_NEWLINES = sys.version_info[:2] != (2, 7) and sys.version_info < (3, 2)


diff -r d50ce2daf212727b324e43b26b838e78612102ed -r 1e9f8d37d4bf6f51aa651546ed37c5579a30fec7 testing/test_assertrewrite.py
--- a/testing/test_assertrewrite.py
+++ b/testing/test_assertrewrite.py
@@ -1,3 +1,4 @@
+import os
 import sys
 import zipfile
 import py
@@ -352,6 +353,7 @@
 
     @pytest.mark.skipif('"__pypy__" in sys.modules')
     def test_pyc_vs_pyo(self, testdir, monkeypatch):
+        import _pytest.assertion.rewrite
         testdir.makepyfile("""
 import pytest
 def test_optimized():
@@ -362,8 +364,12 @@
         tmp = "--basetemp=%s" % p
         monkeypatch.setenv("PYTHONOPTIMIZE", "2")
         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()
         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):
         pkg = testdir.tmpdir.join("pkg")

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the pytest-commit mailing list