[TIP] tox, 2to3 and py.test
marius at gedmin.as
Tue Apr 3 06:34:34 PDT 2012
On Tue, Apr 03, 2012 at 08:57:38AM +0000, Florian Bauer wrote:
> > From: Eduardo Schettino [mailto:schettino72 at gmail.com]
> > On Mon, Apr 2, 2012 at 4:11 PM, Florian Bauer
> > <Florian.Bauer at diasemi.com> wrote:
> >> The py.test documentation recommends that test/ should not be a
> >> package, and I understand why.
> > I dont really understand why... and I could not find any
> > reference in the docs on why this is recommended. Can someone
> > please explain it?
> Good that you ask, I think this point is a bit subtle.
> The reason why you couldn't find anything in the docs is because I
> gave the wrong reference, it is actually in the tox docs at the bottom
> of the page here: http://tox.testrun.org/latest/example/pytest.html
> My project in its current form is a good example of the pitfalls of having a test package
> Say this is my source code layout:
> test_spam.py starts with
> from mypackage.spam import eggs
> if I now run py.test from my source directory, it would walk the file
> system and find the file mypackage/test/test_spam.py Then it
> constructs the fully qualified name of this file, which is
> mypackage.test.test_spam , as it is part of a package, and imports it.
> Likewise, mypackage.spam gets imported as well. As long as I call
> py.test from the source directory, I know that I imported the files
> mypackage/spam.py and mypackage/test/test_spam.py
> The fun begins in conjunction with tox and similar tools. Tox is
> supposed to run code installed in a private a virtualenv, say
> .tox/py26/lib/site-packages/mypackage or
> .tox/py32/lib/site-packages/mypackage Which, in the given scenario it
> won't do, because mypackage/test/test_spam comes earlier on the module
> search path.
Why can't tox use setup.py develop so there's only one copy of the
source files? Is that incompatible with 2to3?
Why is . in the python path anyway?
> I showed a tox.ini in my first e-mail that works around the issue, but
> it took some time to figure out, why python3 was importing modules
> containing python 2 syntax ;)
Q: Is the Zombie Apocalypse a likely occurrence?
A: It happens every morning when people drag their ass out of bed to go to
work. We seem to survive it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: Digital signature
More information about the testing-in-python