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

Re: running tests against installed version of package



[Thomas Goirand, 2016-04-06]
> Don't use py.test-FOO, as this is deprecated. Instead, use something
> like this:
> 
> PYTHON3S:=$(shell py3versions -vr)
> 
> override_dh_auto_test:
> ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
>         @echo "===> Running tests"
>         set -e ; set -x ; for i in 2.7 $(PYTHON3S) ; do \
> 		PYTHONPATH=. python$$i -m pytest ; \
> 	done
> endif
> 
> Note that you can hardcode 2.7, as we will keep this version for Python2
> basically forever (or until Python 2 completely dies), so it doesn't
> really mater.

hardcoding 2.7 is OK

> Having multiple version of Py3 supported also helps backporting from Sid
> to Jessie, and also supports future version of Py3 (as Brian wrote).
> 
> Last, as Piotr wrote, PYTHONPATH=. isn't enough for non pure-python
> stuff. In this type of case, there are other workarounds (which I can

again, testing sources, even without extensions is not something we
should do. If testing if all files are installed doesn't convince you,
how about 2to3 changes not applied while testing Python 3.X?

> tell if you need them). What I personally do is that I get things built
> and installed within debian/tmp. That's the most easy way, a lot more
> than double-guessing the build/* folder names. This also has the
> advantage that the egg-info gets (re-)generated in the correct place. In
> such case, you will want to do something like this:
> 
> python setup.py install --install-layout=deb \
> 	--root=$(CURDIR)/debian/tmp
> PYTHONPATH=$(CURDIR)/debian/tmp/usr/lib/python2.7/dist-packages \
> 	PYTHONPATH=. python -m pytest
> 
> Combine this with the loop for multiple version of Python above, and you
> got (nearly) everything covered.

... and you will end up in debian/rules that is 5 times bigger than
before and once pytest's interface changes, your package FTBFS - that's
OK if you have time to update all your packages, but if you, like me,
are lazy, then you can use "not very helpful for running tests" pybuild
that does all above and more for you.
-- 
Piotr Ożarowski                         Debian GNU/Linux Developer
www.ozarowski.pl          www.griffith.cc           www.debian.org
GPG Fingerprint: 1D2F A898 58DA AF62 1786 2DF7 AEF6 F1A2 A745 7645


Reply to: