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

Attachment: signature.asc
Description: PGP signature

Reply via email to