On 18-04-18, Levente Polyak wrote:
> On April 18, 2018 11:53:01 AM GMT+02:00, Baptiste Jonglez 
> <[email protected]> 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:

    cd "$srcdir/pybtex-$pkgver"
    export PYTHONPATH="$srcdir/pybtex-$pkgver"
    nosetests

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:

    cd "$srcdir/pybtex-$pkgver/build/lib"
    export PYTHONPATH="$srcdir/pybtex-$pkgver/build/lib"
    nosetests

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?

Thanks,
Baptiste

Attachment: signature.asc
Description: PGP signature

Reply via email to