Tests in python packages

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Tests in python packages

Sebastian-2
Hi,

I'm currently trying to package a python-lib which includes some c-code
and face some issues for running the automatic tests.

For normal packages, the test can be run quite simply. E.g. tests are in
tests/, you add .. to the python path and then run nose or unittests. An
ugly too, but it works.

For compiled files I can't do this trick, because I need to get the
compiled resources in site-packages. In chroot I can run this:
PYTHONPATH=/home/abuild/rpmbuild/BUILDROOT/python3-pyasn-1.5.0b7-0.x86_64/usr/lib64/python3.5/site-packages/
python3 -c "import pyasn.pyasn_radix"

But I can't use this in the spec-file. I only get
/home/abuild/rpmbuild/BUILDROOT/python3-pyasn-1.5.0b7-0.x86_64/ as
%{buildroot}, but %{python_sitearch} seems to be empty.
Do you have any hints how to accomplish this?

The package in question:
https://build.opensuse.org/package/show/home:sebix/python3-pyasn

--
python programming - mail server - photo - video - https://sebix.at
cryptographic key at https://sebix.at/DC9B463B.asc and on public keyservers



signature.asc (860 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Tests in python packages

Jason Craig-3
On 07/30/2016 08:14 AM, Sebastian wrote:
> Hi,
>
> I'm currently trying to package a python-lib which includes some c-code
> and face some issues for running the automatic tests.
>
> For normal packages, the test can be run quite simply. E.g. tests are in
> tests/, you add .. to the python path and then run nose or unittests. An
> ugly too, but it works.

For normal packages, don't you just do something like
  python[3] setup.py test
?

> For compiled files I can't do this trick, because I need to get the
> compiled resources in site-packages. In chroot I can run this:
> PYTHONPATH=/home/abuild/rpmbuild/BUILDROOT/python3-pyasn-1.5.0b7-0.x86_64/usr/lib64/python3.5/site-packages/
> python3 -c "import pyasn.pyasn_radix"
>
> But I can't use this in the spec-file. I only get
> /home/abuild/rpmbuild/BUILDROOT/python3-pyasn-1.5.0b7-0.x86_64/ as
> %{buildroot}, but %{python_sitearch} seems to be empty.
> Do you have any hints how to accomplish this?

Well, since it is a Python 3 and not 2 package I believe the macro you
are looking for is %{python3_sitearch}. I do not, however, understand
what the problem is so I can't be of more help.

> The package in question:
> https://build.opensuse.org/package/show/home:sebix/python3-pyasn
>

--
Jason Craig
--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Tests in python packages

Sebastian-2
Hi,

On 07/30/2016 06:57 PM, Jason Craig wrote:

> On 07/30/2016 08:14 AM, Sebastian wrote:
>> Hi,
>>
>> I'm currently trying to package a python-lib which includes some c-code
>> and face some issues for running the automatic tests.
>>
>> For normal packages, the test can be run quite simply. E.g. tests are in
>> tests/, you add .. to the python path and then run nose or unittests. An
>> ugly too, but it works.
>
> For normal packages, don't you just do something like
>  python[3] setup.py test
> ?
Sometime the easiest solution is not so far. Thanks, for this package it
works well.
For packages not providing the test-command, one has to patch it in tough.

I documented it in the wiki too now:
https://en.opensuse.org/openSUSE:Packaging_Python#Running_tests

Sebastian

--
python programming - mail server - photo - video - https://sebix.at
cryptographic key at https://sebix.at/DC9B463B.asc and on public keyservers



signature.asc (860 bytes) Download Attachment