[TIP] py.test plugin: setuptools problems
geoff.bache at gmail.com
Thu Mar 10 00:10:35 PST 2011
> just to be sure I guess you have seen this (?):
Yes, I've been reading there...
> 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.
It's no good putting it in the testing directory, as I want to
distribute it and make it convenient to use my package from py.test (I
don't actually use py.test myself, ordinarily). It probably won't be
if people need to know that they have to copy a conftest.py file to
their tests before it will work.
If it's under my package, how will py.test find it? I tried before
setting the variable "pytest_plugins" in my test but that didn't work.
The problem is that my plugin adds additional command line options to
py.test (indeed, that's the point of it) so presumably it's "too late"
by the time it finds my tests or my package.
> 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
I didn't understand what this was for. Would I then distribute this
script and tell people to run it instead of using py.test directly?
>> 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?
No. But they are checked in to the same repository, so the two
setup.py files are alongside each other in the same location. (I also
tried having two separate setup(...) calls in the same file)
>> 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:
> and maybe use it as a skeleton to work for your purposes?
> (if the conftest.py solution above is somehow not sufficient).
I've been using pytest-cov as a skeleton and I think I understand how
to write the plugin. It's making it available that's the hard part...
More information about the testing-in-python