Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e652c8b

Browse filesBrowse files
authored
Merge pull request #13795 from anntzer/warnexternal-tests
Make _warn_external correctly report warnings arising from tests.
2 parents 366a5d1 + d7726a3 commit e652c8b
Copy full SHA for e652c8b

File tree

Expand file treeCollapse file tree

2 files changed

+7
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-1
lines changed

‎lib/matplotlib/cbook/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook/__init__.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,7 @@ def _warn_external(message, category=None):
20412041
if frame is None:
20422042
# when called in embedded context may hit frame is None
20432043
break
2044-
if not re.match(r"\A(matplotlib|mpl_toolkits)(\Z|\.)",
2044+
if not re.match(r"\A(matplotlib|mpl_toolkits)(\Z|\.(?!tests\.))",
20452045
# Work around sphinx-gallery not setting __name__.
20462046
frame.f_globals.get("__name__", "")):
20472047
break

‎lib/matplotlib/tests/test_cbook.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_cbook.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,3 +560,9 @@ def func(pre, arg, post=None):
560560
func(1, 2)
561561
with pytest.warns(MatplotlibDeprecationWarning):
562562
func(1, 2, 3)
563+
564+
565+
def test_warn_external(recwarn):
566+
cbook._warn_external("oops")
567+
assert len(recwarn) == 1
568+
assert recwarn[0].filename == __file__

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.