[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: running tests against installed version of package



On 03/25/2016 08:17 AM, Brian May wrote:
> Hello,
> 
> By default pybuild runs tests I think using the source tree.

In most cases, Pybuild isn't very helpful for running tests and fails in
the most common traps (like the one I'm solving for you below), which is
why I don't really think it's useful at all. YMMV...

> However I have a package where the tests require the entry points from
> setup.py to be configured, the tests fail without this.

Most of the time, you get by this doing:
PYTHONPATH=$(CURDIR) python -m pytest tests

If this doesn't work (maybe because you need the egg-info which isn't in
the tarball, or otherwise...), then get the package installed first:

python setup.py install --install-layout=deb \
	--root $(CURDIR)/debian/tmp
PYTHONPATH=$(CURDIR)/debian/tmp python -m pytest tests

In the case of apscheduler, simply defining PYTHONPATH=. is enough, then
unit tests failing are those trying to connect to a local redis server
which may be fixed by manually starting redis-server from your
debian/rules (take care: you *must* start it on a non-standard port or
unix file-socket, and get your unit tests to use that non-standard port,
otherwise you'll be in trouble either in sbuild, or in non-sbuild).

By doing the above, I was able to run *all* of the unit tests of
apscheduler (ie: 404 tests, minus the 7 tests which got automatically
skipped).

I hope this helps, even though you probably will not maintain this
package. Hopefully, it will help you for the next one! :)

Cheers,

Thomas Goirand (zigo)


Reply to: