From 9ea6a1ca8f592d089827762137a5a3f2d3ce1fd4 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Mon, 25 Mar 2024 11:03:09 -0400 Subject: [PATCH] Use pytest-env to capture warnings on CI runs (#1107) --- pyproject.toml | 4 ++++ xcp_d/config.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 80945d5f5..7b6dda5ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,6 +78,7 @@ tests = [ "pep8-naming", "pytest", "pytest-cov", + "pytest-env", ] maint = [ "fuzzywuzzy", @@ -176,6 +177,9 @@ markers = [ "fmriprep_without_freesurfer: mark integration test for fMRIPrep derivatives without FreeSurfer", "nibabies: mark integration test for nibabies derivatives", ] +env = [ + "RUNNING_PYTEST = 1", +] [tool.coverage.run] branch = true diff --git a/xcp_d/config.py b/xcp_d/config.py index 320840481..2f3fe2d0f 100644 --- a/xcp_d/config.py +++ b/xcp_d/config.py @@ -117,8 +117,9 @@ if not hasattr(sys, "_is_pytest_session"): sys._is_pytest_session = False # Trick to avoid sklearn's FutureWarnings + # Disable all warnings in main and children processes only on production versions -if not any( +if ("RUNNING_PYTEST" not in os.environ) and not any( ( "+" in __version__, __version__.endswith(".dirty"), @@ -463,7 +464,7 @@ def init(cls): if cls.participant_label: # Ignore any subjects who aren't the requested ones. ignore_patterns.append( - re.compile(r'sub-(?!' + '|'.join(cls.participant_label) + r')\w+') + re.compile(r"sub-(?!" + "|".join(cls.participant_label) + r")\w+") ) _indexer = BIDSLayoutIndexer(