only use the last part of the module name in the filename (fixes #68)

This commit is contained in:
Benjamin Peterson 2011-08-30 00:12:07 -04:00
parent abe080c6b4
commit 661a8a4a92
3 changed files with 11 additions and 1 deletions

View File

@ -1,6 +1,7 @@
Changes between 2.1.1 and [NEXT VERSION]
----------------------------------------
- fix issue68 / packages now work with assertion rewriting
- fix issue66: use different assertion rewriting caches when the -O option is passed
Changes between 2.1.0 and 2.1.1

View File

@ -77,7 +77,7 @@ class AssertionRewritingHook(object):
# Don't know what this is.
return None
else:
fn = os.path.join(pth, name + ".py")
fn = os.path.join(pth, name.rpartition(".")[2] + ".py")
fn_pypath = py.path.local(fn)
# Is this a test file?
if not sess.isinitpath(fn):

View File

@ -340,3 +340,12 @@ def test_optimized():
assert testdir.runpybin("py.test", tmp).ret == 0
monkeypatch.undo()
assert testdir.runpybin("py.test", tmp).ret == 1
def test_package(self, testdir):
pkg = testdir.tmpdir.join("pkg")
pkg.mkdir()
pkg.join("__init__.py").ensure()
pkg.join("test_blah.py").write("""
def test_rewritten():
assert "@py_builtins" in globals()""")
assert testdir.runpytest().ret == 0