Skip to content

Commit 608b51f

Browse files
committed
Create tests
1 parent e57b321 commit 608b51f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

lib/matplotlib/tests/test_pyplot.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import difflib
2+
import inspect
23

34
import numpy as np
45
import sys
@@ -449,7 +450,6 @@ def figure_hook_example(figure):
449450

450451

451452
def test_figure_hook():
452-
453453
test_rc = {
454454
'figure.hooks': ['matplotlib.tests.test_pyplot:figure_hook_example']
455455
}
@@ -484,3 +484,24 @@ def test_matshow():
484484

485485
# Smoke test that matshow does not ask for a new figsize on the existing figure
486486
plt.matshow(arr, fignum=fig.number)
487+
488+
489+
def assert_signatures_identical(plt_meth, original_meth, remove_self_param=False):
490+
plt_params = inspect.signature(plt_meth).parameters
491+
original_params = inspect.signature(original_meth).parameters
492+
if remove_self_param:
493+
if next(iter(original_params)) not in ["self"]:
494+
raise AssertionError(f"{original_params} is not an instance method")
495+
496+
original_params = dict(original_params)
497+
del original_params["self"]
498+
499+
assert plt_params == original_params
500+
501+
502+
def test_setloglevel_signature():
503+
assert_signatures_identical(plt.set_loglevel, mpl.set_loglevel)
504+
505+
506+
def test_polar_signature():
507+
assert_signatures_identical(plt.polar, plt.Axes.plot, True)

0 commit comments

Comments
 (0)