[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: dh_auto_test failure with pybuild due to missing PYTHONPATH



On 2020-10-04 04 h 21, Florian Weimer wrote:
> I'm trying to package git-pw, and running the test suite fails like
> this:
> 
>    dh_auto_test -O--buildsystem=pybuild
> I: pybuild base:217: cd /build/git-pw-2.0.0/.pybuild/cpython3_3.8_git-pw/build; python3.8 -m pytest tests
> =========================================== test session starts ===========================================
> platform linux -- Python 3.8.6, pytest-4.6.11, py-1.9.0, pluggy-0.13.0
> rootdir: /build/git-pw-2.0.0
> collected 0 items / 5 errors                                                                              
> 
> ================================================= ERRORS ==================================================
> __________________ ERROR collecting .pybuild/cpython3_3.8_git-pw/build/tests/test_api.py __________________
> tests/test_api.py:6: in <module>
>     from git_pw import api
> git_pw/__init__.py:8: in <module>
>     __version__ = pkg_resources.get_distribution('git-pw').version
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:480: in get_distribution
>     dist = get_provider(dist)
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:356: in get_provider
>     return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:899: in require
>     needed = self.resolve(parse_requirements(requirements))
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:785: in resolve
>     raise DistributionNotFound(req, requirers)
> E   pkg_resources.DistributionNotFound: The 'git-pw' distribution was not found and is required by the application
> ________________ ERROR collecting .pybuild/cpython3_3.8_git-pw/build/tests/test_bundle.py _________________
> tests/test_bundle.py:7: in <module>
>     from git_pw import bundle
> git_pw/__init__.py:8: in <module>
>     __version__ = pkg_resources.get_distribution('git-pw').version
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:480: in get_distribution
>     dist = get_provider(dist)
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:356: in get_provider
>     return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:899: in require
>     needed = self.resolve(parse_requirements(requirements))
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:785: in resolve
>     raise DistributionNotFound(req, requirers)
> E   pkg_resources.DistributionNotFound: The 'git-pw' distribution was not found and is required by the application
> _________________ ERROR collecting .pybuild/cpython3_3.8_git-pw/build/tests/test_patch.py _________________
> tests/test_patch.py:9: in <module>
>     from git_pw import patch
> git_pw/__init__.py:8: in <module>
>     __version__ = pkg_resources.get_distribution('git-pw').version
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:480: in get_distribution
>     dist = get_provider(dist)
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:356: in get_provider
>     return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:899: in require
>     needed = self.resolve(parse_requirements(requirements))
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:785: in resolve
>     raise DistributionNotFound(req, requirers)
> E   pkg_resources.DistributionNotFound: The 'git-pw' distribution was not found and is required by the application
> ________________ ERROR collecting .pybuild/cpython3_3.8_git-pw/build/tests/test_series.py _________________
> tests/test_series.py:7: in <module>
>     from git_pw import series
> git_pw/__init__.py:8: in <module>
>     __version__ = pkg_resources.get_distribution('git-pw').version
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:480: in get_distribution
>     dist = get_provider(dist)
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:356: in get_provider
>     return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:899: in require
>     needed = self.resolve(parse_requirements(requirements))
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:785: in resolve
>     raise DistributionNotFound(req, requirers)
> E   pkg_resources.DistributionNotFound: The 'git-pw' distribution was not found and is required by the application
> _________________ ERROR collecting .pybuild/cpython3_3.8_git-pw/build/tests/test_utils.py _________________
> tests/test_utils.py:11: in <module>
>     from git_pw import utils
> git_pw/__init__.py:8: in <module>
>     __version__ = pkg_resources.get_distribution('git-pw').version
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:480: in get_distribution
>     dist = get_provider(dist)
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:356: in get_provider
>     return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:899: in require
>     needed = self.resolve(parse_requirements(requirements))
> /usr/lib/python3/dist-packages/pkg_resources/__init__.py:785: in resolve
>     raise DistributionNotFound(req, requirers)
> E   pkg_resources.DistributionNotFound: The 'git-pw' distribution was not found and is required by the application
> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 5 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> ========================================= 5 error in 0.40 seconds =========================================
> E: pybuild pybuild:352: test: plugin distutils failed with: exit code=2: cd /build/git-pw-2.0.0/.pybuild/cpython3_3.8_git-pw/build; python3.8 -m pytest tests
> dh_auto_test: error: pybuild --test --test-pytest -i python{version} -p 3.8 returned exit code 13
> 
> Apparently, the test suite expects PYTHONPATH to be set.  Is there a
> way to achieve this in a clean way?

You could use "export PYBUILD_BEFORE_TEST=PYTHONPATH=" to tell pybuild
to run a command before the testsuite is ran.

I'd consider that "cleaner" than overriding dh_auto_test.

> Adding this to debian/rules works:
> 
> override_dh_auto_test:
> 	PYTHONPATH=. pytest-3 tests
> 
> But it won't run the tests against the installed binaries.

Not sure I understand what you mean by "against the installed binaries".
The testsuite ran during build isn't ran against installed binaries,
that's why we use autopkgtests.

Here is an example of an autopkgtest running the testsuite and exporting
a python path:

https://sources.debian.org/src/supysonic/0.6.0+ds-1/debian/tests/unittests/?hl=4#L4


-- 
  ⢀⣴⠾⠻⢶⣦⠀
  ⣾⠁⢠⠒⠀⣿⡁  Louis-Philippe Véronneau
  ⢿⡄⠘⠷⠚⠋   pollo@debian.org / veronneau.org
  ⠈⠳⣄

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: