[TIP] py.test plugin: setuptools problems

holger krekel holger at merlinux.eu
Wed Mar 9 13:46:39 PST 2011


Hi Geoff!

On Wed, Mar 09, 2011 at 22:19 +0100, Geoff Bache wrote:
> Hi all, (Holger especially...)
> 
> I'm trying to write a minimal py.test plugin to go with a new package
> I'm writing, and am having loads of trouble making the setuptools
> aspect of it work. As I understand it, I have to define a "setuptools
> entry point" for it in order for py.test to find it.

just to be sure I guess you have seen this (?):

    http://pytest.org/plugins.html?highlight=pytest11#making-your-plugin-installable-by-others

> As there's currently only five lines of it it seems somewhat overkill
> to have a completely separate package for it - would seem easier to
> just check it in with my package (which doesn't use setuptools
> currently) and have a separate setup operation for it. I'm having a
> lot of trouble making that work though.

> So, my questions/requests :
> 1) I would love to have a way to write a py.test plugin that didn't
> require using setuptools. I find it complex, hard to use and poorly
> documented, and every new egg makes our sys.path even longer and all
> our Python programs slower...

You could probably just put a conftest.py into your testing directory
or into the root directory of your package.  This constitutes a
"local" or project-specific plugin and is automatically detected
when you run py.test.  No setuptools entry point logic required.

And if you then use "py.test --genscript=mypytest" you have a "myptest.py"
script that can be used to run the tests without any installation
script.

> 2) Any guesses why setuptools would be installing every Python file it
> could find under the current working directory in this new "egg"? I
> have specified "py_modules" to a single file, but still get everything
> (basically a duplicate copy of the whole 'real' package).

I am not sure i understand.  Are you using the same setup.py
for both the plugin and your package?

> 3) Is there any way to tell setuptools not to make an egg? Or even to
> just create an "entry point" without installing anythiing? All I want
> is for my 5 lines of python to appear in a nice simple .py file
> somewhere it can be imported :)

I pass on that one but maybe it helps if take a look at this small 
PEP8 verification plugin:

    https://bitbucket.org/hpk42/pytest-pep8/src
   
and maybe use it as a skeleton to work for your purposes?
(if the conftest.py solution above is somehow not sufficient).

best,
holger


> 
> Regards,
> Geoff
> 
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
> 



More information about the testing-in-python mailing list