[arch-dev-public] Unit tests for python packages
Baptiste Jonglez
baptiste at bitsofnetworks.org
Wed Apr 18 09:53:01 UTC 2018
Hi,
Does anyone have experience with unit tests for python packages? It's
really useful to spot missing runtime dependencies, but it's a pain to get
to work.
Here is what I saw:
1) just running "python -m unittest discover" or "nosetests" or equivalent
in the check() function does not work, because the package is not yet
installed (so all imports will fail)
2) setuptools is supposed to have a unittest integration such that
"python setup.py test" should work out of the box, but in my case it
never finds any tests to run
3) I've seen some more... "creative" solutions :)
https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/python-coverage#n28
So far, the only working solution I found is playing with PYTHONPATH:
cd "$srcdir/$pkgname-$pkgver/tests"
export PYTHONPATH="$srcdir/$pkgname-$pkgver/src"
python -m unittest discover
But it's a hack, and it probably won't work with things like 2to3.
Any better ideas?
Baptiste
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.archlinux.org/pipermail/arch-dev-public/attachments/20180418/9245bc8b/attachment.asc>
More information about the arch-dev-public
mailing list