[arch-dev-public] Unit tests for python packages
baptiste at bitsofnetworks.org
Wed Apr 18 13:04:54 UTC 2018
On 18-04-18, Levente Polyak wrote:
> On April 18, 2018 11:53:01 AM GMT+02:00, Baptiste Jonglez <baptiste at bitsofnetworks.org> wrote:
> >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
> If you use a build function there shouldn't be any problems like 2to3
> while running tests, everything should be converted / build and
> generated for the use of tests.
I do use a build function: https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/python-pybtex
The problem is that this package is written in python2 and relies on 2to3.
If I just run the tests with python3 in the source directory, like this:
it fails with lots of syntax errors, because the code is python2.
I tried to run the tests in the build directory, where 2to3 has been applied:
It works better, but a lot of tests fail because they can't load some
stuff from the package: https://paste.aliens-lyon.fr/vam
The same tests with python2 work fine in the source dir, and fail in the
build/lib dir. So there's something strange going on with the build dir.
> For certain upstream test setups there won't be much you can do other then PYTHONPATH but as mentioned with a build function it should always work.
> You can give python-pytest-runner a go, it does proper resolution while running "python setup.py test" but requires certain ways the whole test suites are wired.
It looks like this will only work for packages that use pytest?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: not available
More information about the arch-dev-public