Re: [RFH] Running Python tests that require the source to be installed
Hi Andrey,
thanks a lot for the fast and already helpful reply!
On Thu, 2024-10-24 at 16:03 +0500, Andrey Rakhmatullin wrote:
> On Thu, Oct 24, 2024 at 12:44:45PM +0200, John Paul Adrian Glaubitz wrote:
> > (Please CC as I'm not subscribed to debian-devel)
>
> (this is how I realized this is not debian-python@, consider using that
> for more relevant coverage)
Duly noted!
> > I am maintaining the package src:kiwi [1] which hasn't been updated in
> > Debian for some time since upstream has added tests that only work when
> > the package source is installed into the test environment, i.e. available
> > through PYTHONPATH.
>
> I believe any or at least most Python unittests require the module being
> tested to be available in sys.path and pybuild already helps with that, by
> running tests in a directory with the package installed, is that not
> enough? What are the specific problems you have?
I had to look it up and the mechanism used is called "entry_points". The kiwi
package adds such entry_points and wants to test them in its testsuite.
Thus, I need to figure out how to make those entry_points visible from the
build environment so that the testsuite can find and test them.
Is there any other Debian Python package that uses entry points?
> > I have tried to adjust the environment variables in debian/rules as follows
> > and tried to invoke the testsuite from the test/unit subdirectory:
> >
> > export PYTHONPATH = $(CURDIR)
>
> $(CURDIR) is already in sys.path when running python -m.
>
> > export PYBUILD_TEST_ARGS_python3 = cd {build_dir}; python{version} -m discover
> >
> > override_dh_auto_test:
> > ifeq ($(filter nocheck nobench, $(DEB_BUILD_OPTIONS)),)
> > /bin/sh -c "cd test/unit && pytest-3"
> You should use python* -m pytest (note that you need to run it for all
> supported Python versions.
OK, thanks.
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Reply to: