Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build-style/python3-module: prefer pytest in do_check #26901

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions common/build-style/python3-module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,20 @@ do_build() {
}

do_check() {
if [ -z "$make_check_target" ]; then
if ! python3 setup.py --help test >/dev/null 2>&1; then
msg_warn "No command 'test' defined by setup.py.\n"
return 0
if python3 -m pytest --help >/dev/null 2>&1; then
python3 -m pytest ${make_check_args} ${make_check_target}
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this is better:

PYTHONPATH="$(cd build/lib* && pwd)" python3 -m pytest ${make_check_args} ${make_check_target}

Copy link
Member Author

Choose a reason for hiding this comment

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

Setting PYTHONPATH this way might improve support for testing compiled extensions, but I'm not sure it should be the default. If tests break because they can't be run with the default path (plus ., which is automatically added in the python3 -m pytest form of invocation), maybe that should be a manual override situation.

else
Comment on lines +27 to +29
Copy link
Member

Choose a reason for hiding this comment

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

I'm not against leaving a historical comment like "we don't try to use tox because ...."

# Fall back to deprecated setup.py test orchestration without pytest
if [ -z "$make_check_target" ]; then
if ! python3 setup.py --help test >/dev/null 2>&1; then
msg_warn "No command 'test' defined by setup.py.\n"
return 0
fi
fi
fi

: ${make_check_target:=test}
python3 setup.py ${make_check_target} ${make_check_args}
: ${make_check_target:=test}
python3 setup.py ${make_check_target} ${make_check_args}
fi
}

do_install() {
Expand Down
4 changes: 0 additions & 4 deletions srcpkgs/python3-lz4/template
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ changelog="https://github.com/python-lz4/python-lz4/releases"
distfiles="${PYPI_SITE}/l/lz4/lz4-${version}.tar.gz"
checksum=1ac354804cb2d5fb3d213857a6bf8590a301ef051cc16fbb4938bd2d6e524bda

do_check() {
python3 -m pytest
}

post_install() {
vlicense LICENSE
}
4 changes: 0 additions & 4 deletions srcpkgs/python3-tifffile/template
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ changelog="https://raw.githubusercontent.com/cgohlke/tifffile/master/CHANGES.rst
distfiles="${homepage}/archive/v${version}.tar.gz"
checksum=64fc7602330301e910cc343e99bac02f9b453e933c1ee2050f316cbfee725df3

do_check() {
python3 -m pytest
}

post_install() {
vlicense LICENSE
}
4 changes: 0 additions & 4 deletions srcpkgs/virt-manager/template
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ distfiles="https://virt-manager.org/download/sources/${pkgname}/${pkgname}-${ver
checksum=2b6fe3d90d89e1130227e4b05c51e6642d89c839d3ea063e0e29475fd9bf7b86
python_version=3

do_check() {
python3 -m pytest
}

post_install() {
rm $DESTDIR/usr/share/glib-2.0/schemas/gschemas.compiled \
$DESTDIR/usr/share/icons/hicolor/icon-theme.cache
Expand Down