From 6f7f01a2448283427301bcfa1927f01c361943e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 6 Jan 2021 00:32:27 +0100 Subject: [PATCH] pytestCheckHook: Add disabledTestFiles option --- doc/languages-frameworks/python.section.md | 4 ++++ .../interpreters/python/hooks/pytest-check-hook.sh | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/doc/languages-frameworks/python.section.md b/doc/languages-frameworks/python.section.md index 2dea2cb1bcc9..71193ed0cc0b 100644 --- a/doc/languages-frameworks/python.section.md +++ b/doc/languages-frameworks/python.section.md @@ -610,6 +610,10 @@ Using the example above, the analagous pytestCheckHook usage would be: "download" "update" ]; + + disabledTestFiles = [ + "tests/test_failing.py" + ]; ``` This is expecially useful when tests need to be conditionallydisabled, diff --git a/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh b/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh index bfd2bfa75836..c2079fa84f90 100644 --- a/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh +++ b/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh @@ -2,6 +2,7 @@ echo "Sourcing pytest-check-hook" declare -ar disabledTests +declare -ar disabledTestFiles function _concatSep { local result @@ -36,6 +37,13 @@ function pytestCheckPhase() { disabledTestsString=$(_pytestComputeDisabledTestsString "${disabledTests[@]}") args+=" -k \""$disabledTestsString"\"" fi + for file in "${disabledTestFiles[@]}"; do + if [ ! -f "$file" ]; then + echo "Disabled test file \"$file\" does not exist. Aborting" + exit 1 + fi + args+=" --ignore=$file" + done args+=" ${pytestFlagsArray[@]}" eval "@pythonCheckInterpreter@ $args"