1 |
Support (potentially global-scope) EPYTEST_DESELECT and EPYTEST_IGNORE |
2 |
arrays to conveniently deselect/skip tests. This effectively replaces |
3 |
local hacks such as: |
4 |
|
5 |
epytest ${deselect[@]/#/--deselect } |
6 |
|
7 |
Signed-off-by: Michał Górny <mgorny@g.o> |
8 |
--- |
9 |
eclass/python-utils-r1.eclass | 30 ++++++++++++++++++++++++++++-- |
10 |
1 file changed, 28 insertions(+), 2 deletions(-) |
11 |
|
12 |
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass |
13 |
index b104b6694ac3..356ace6a6851 100644 |
14 |
--- a/eclass/python-utils-r1.eclass |
15 |
+++ b/eclass/python-utils-r1.eclass |
16 |
@@ -1244,11 +1244,30 @@ build_sphinx() { |
17 |
HTML_DOCS+=( "${dir}/_build/html/." ) |
18 |
} |
19 |
|
20 |
+# @VARIABLE: EPYTEST_DESELECT |
21 |
+# @DEFAULT_UNSET |
22 |
+# @DESCRIPTION: |
23 |
+# Specifies an array of tests to be deselected via pytest's --deselect |
24 |
+# parameter, when calling epytest. The list can include file paths, |
25 |
+# specific test functions or parametrized test invocations. |
26 |
+# |
27 |
+# Note that the listed files will still be subject to collection, |
28 |
+# i.e. modules imported in global scope will need to be available. |
29 |
+# If this is undesirable, EPYTEST_IGNORE can be used instead. |
30 |
+ |
31 |
+# @VARIABLE: EPYTEST_IGNORE |
32 |
+# @DEFAULT_UNSET |
33 |
+# @DESCRIPTION: |
34 |
+# Specifies an array of paths to be ignored via pytest's --ignore |
35 |
+# parameter, when calling epytest. The listed files will be entirely |
36 |
+# skipped from test collection. |
37 |
+ |
38 |
# @FUNCTION: epytest |
39 |
# @USAGE: [<args>...] |
40 |
# @DESCRIPTION: |
41 |
-# Run pytest, passing the standard set of pytest options, followed |
42 |
-# by user-specified options. |
43 |
+# Run pytest, passing the standard set of pytest options, then |
44 |
+# --deselect and --ignore options based on EPYTEST_DESELECT |
45 |
+# and EPYTEST_IGNORE, then user-specified options. |
46 |
# |
47 |
# This command dies on failure and respects nonfatal. |
48 |
epytest() { |
49 |
@@ -1268,6 +1287,13 @@ epytest() { |
50 |
# for end users, as it tends to fail on new warnings from deps |
51 |
-Wdefault |
52 |
) |
53 |
+ local x |
54 |
+ for x in "${EPYTEST_DESELECT[@]}"; do |
55 |
+ args+=( --deselect "${x}" ) |
56 |
+ done |
57 |
+ for x in "${EPYTEST_IGNORE[@]}"; do |
58 |
+ args+=( --ignore "${x}" ) |
59 |
+ done |
60 |
set -- "${EPYTHON}" -m pytest "${args[@]}" "${@}" |
61 |
|
62 |
echo "${@}" >&2 |
63 |
-- |
64 |
2.32.0 |