Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] build-style/python3-{module,pep517}.sh: fix check for pytest
@ 2021-06-08  3:48 ahesford
  2021-06-08  4:16 ` [PR PATCH] [Updated] " ahesford
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ahesford @ 2021-06-08  3:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 721 bytes --]

There is a new pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages pytest
https://github.com/void-linux/void-packages/pull/31354

build-style/python3-{module,pep517}.sh: fix check for pytest
Relying on `python3 -m pytest --help` to test for pytest can fail
because the pytest packages's __main__ is still invoked; this can
trigger import problems and falsely indicate that pytest is missing.

A simpler test is to just confirm that pytest is importable. If so, the
interpreter returns 0. Otherwise, an ImportError is thrown and the
interpreter will return 1.


A patch file from https://github.com/void-linux/void-packages/pull/31354.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pytest-31354.patch --]
[-- Type: text/x-diff, Size: 1763 bytes --]

From a00727b9dd903a14ee9d7684585dc4103145fa30 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 7 Jun 2021 23:41:26 -0400
Subject: [PATCH] build-style/python3-{module,pep517}.sh: fix check for pytest

Relying on `python3 -m pytest --help` to test for pytest can fail
because the pytest packages's __main__ is still invoked; this can
trigger import problems and falsely indicate that pytest is missing.

A simpler test is to just confirm that pytest is importable. If so, the
interpreter returns 0. Otherwise, an ImportError is thrown and the
interpreter will return 1.
---
 common/build-style/python3-module.sh | 2 +-
 common/build-style/python3-pep517.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/build-style/python3-module.sh b/common/build-style/python3-module.sh
index ad5fdff252b3..8b87c2df60bb 100644
--- a/common/build-style/python3-module.sh
+++ b/common/build-style/python3-module.sh
@@ -24,7 +24,7 @@ do_build() {
 }
 
 do_check() {
-	if python3 -m pytest --help >/dev/null 2>&1; then
+	if python3 -c 'import pytest' >/dev/null 2>&1; then
 		python3 -m pytest ${make_check_args} ${make_check_target}
 	else
 		# Fall back to deprecated setup.py test orchestration without pytest
diff --git a/common/build-style/python3-pep517.sh b/common/build-style/python3-pep517.sh
index 4051185a28e6..075f954a1a69 100644
--- a/common/build-style/python3-pep517.sh
+++ b/common/build-style/python3-pep517.sh
@@ -13,7 +13,7 @@ do_build() {
 }
 
 do_check() {
-	if python3 -m pytest --help >/dev/null 2>&1; then
+	if python3 -c 'import pytest' >/dev/null 2>&1; then
 		python3 -m pytest ${make_check_args} ${make_check_target}
 	else
 		msg_warn "Unable to determine tests for PEP517 Python templates"

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-08 17:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08  3:48 [PR PATCH] build-style/python3-{module,pep517}.sh: fix check for pytest ahesford
2021-06-08  4:16 ` [PR PATCH] [Updated] " ahesford
2021-06-08  5:00 ` ahesford
2021-06-08 17:53 ` [PR PATCH] [Closed]: build-style/python3-{module,pep517}.sh: improve pytest usage ahesford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).