Skip to content

Commit

Permalink
dev-python/pytest-subtests: fix tests if pakcage ...
Browse files Browse the repository at this point in the history
is not already installed

Package-Manager: Portage-2.3.96, Repoman-2.3.22
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@riseup.net>
  • Loading branch information
AndrewAmmerlaan committed Apr 3, 2020
1 parent 508368d commit 0e4e63d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dev-python/pytest-subtests/pytest-subtests-0.3.0.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ python_prepare_all() {

distutils-r1_python_prepare_all
}

python_test() {
# tests fail if package is not installed
# workaround is to add source to PYTHONPATH
PYTHONPATH="${S}"
pytest -vv || die
}

3 comments on commit 0e4e63d

@Alessandro-Barbieri
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndrewAmmerlaan
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this fixing pytest-dev/pytest-subtests#21 ?

Uhm, not sure, I didn't get that error ( I think ). I just noticed that tests failed if the package wasn't already installed

Usually this means that the builddir ${WORKDIR}/${PN}-${EPYTHON}/lib (which is added to PYTHONPATH by the default test function) does not contain all the necessary files for testing. Setting PYHTONPATH to the source dir instead makes sure that all the files are available in PYTHONPATH, not just those that will be installed to the system.

When I find that a package tests fail when it is not already installed I always try the PYTHONPATH workaround first, if that doesn't work the distutils-r1_install_for_tests function might help. If it still doesn't work then DEPEND="test? ( ${P} )" might work, but only as a last resort, because circular dependencies are very annoying for end users, because they require manual intervention.

Anyway, pytest-subtests tests now work for me even if the package is not already installed. Does it work for you too? Otherwise we might be missing a dependency here.

@Alessandro-Barbieri
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now work

Please sign in to comment.