summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_utils.py
diff options
context:
space:
mode:
authorSteve Joachim <sgjoachim@gmail.com>2020-10-10 05:47:20 -0400
committerGitHub <noreply@github.com>2020-10-10 10:47:20 +0100
commitaeb23741b1186e6ae525c4dd7f46ce9e1378e670 (patch)
treeedf2f49844fce7e4b78cd5573f8ac9c2985afd67 /numpy/lib/tests/test_utils.py
parentdbb8e993da05b4f12f41cdbc68dbd9733cdd65ab (diff)
downloadnumpy-aeb23741b1186e6ae525c4dd7f46ce9e1378e670.tar.gz
MAINT: Do not emit empty Methods heading in np.info (#17498)
Fixes the incompatible type comparison found in #17490. This also corrects the logic to not print the heading when only private/magic methods are present.
Diffstat (limited to 'numpy/lib/tests/test_utils.py')
-rw-r--r--numpy/lib/tests/test_utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_utils.py b/numpy/lib/tests/test_utils.py
index 261cfef5d..33951b92a 100644
--- a/numpy/lib/tests/test_utils.py
+++ b/numpy/lib/tests/test_utils.py
@@ -140,3 +140,22 @@ class TestByteBounds:
def test_assert_raises_regex_context_manager():
with assert_raises_regex(ValueError, 'no deprecation warning'):
raise ValueError('no deprecation warning')
+
+
+def test_info_method_heading():
+ # info(class) should only print "Methods:" heading if methods exist
+
+ class NoPublicMethods:
+ pass
+
+ class WithPublicMethods:
+ def first_method():
+ pass
+
+ def _has_method_heading(cls):
+ out = StringIO()
+ utils.info(cls, output=out)
+ return 'Methods:' in out.getvalue()
+
+ assert _has_method_heading(WithPublicMethods)
+ assert not _has_method_heading(NoPublicMethods)