Skip to content

Commit 86f88fd

Browse files
gfyoungPingviinituutti
authored andcommitted
STY: Check pytest.raises is used context manager (pandas-dev#24332)
1 parent 7763e40 commit 86f88fd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ci/code_checks.sh

+9
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
148148
invgrep -R --exclude=*.pyc --exclude=testing.py --exclude=test_testing.py assert_raises_regex pandas
149149
RET=$(($RET + $?)) ; echo $MSG "DONE"
150150

151+
# Check that we use pytest.raises only as a context manager
152+
#
153+
# For any flake8-compliant code, the only way this regex gets
154+
# matched is if there is no "with" statement preceding "pytest.raises"
155+
MSG='Check for pytest.raises as context manager (a line starting with `pytest.raises` is invalid, needs a `with` to precede it)' ; echo $MSG
156+
MSG='TODO: This check is currently skipped because so many files fail this. Please enable when all are corrected (xref gh-24332)' ; echo $MSG
157+
# invgrep -R --include '*.py' -E '[[:space:]] pytest.raises' pandas/tests
158+
# RET=$(($RET + $?)) ; echo $MSG "DONE"
159+
151160
MSG='Check that no file in the repo contains tailing whitespaces' ; echo $MSG
152161
invgrep --exclude="*.svg" -RI "\s$" *
153162
RET=$(($RET + $?)) ; echo $MSG "DONE"

0 commit comments

Comments
 (0)