Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate unused testing cleanup mechanisms #17042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/api/api_changes_3.3/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,12 @@ or None is deprecated; set it to "horizontal" instead. Moreover, the two
orientations ("horizontal" and "vertical") will become case-sensitive in the
future.

`CleanupTestCase` and `cleanup` in decorators deprecated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The class `matplotlib.testing.decorators.CleanupTestCase` and the decorator
`matplotlib.testing.decorators.cleanup` are not used in the code base. We have
an automatic cleanup via an auto-used fixture instead.

*minor* kwarg to `.Axis.get_ticklocs` will become keyword-only
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Passing this argument positionally is deprecated.
Empty file added doc/badsectors.txt
Empty file.
52 changes: 0 additions & 52 deletions lib/matplotlib/testing/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,58 +35,6 @@ def _cleanup_cm():
plt.close("all")


class CleanupTestCase(unittest.TestCase):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a deprecation, you have just removed these.

What is the motivation for deprecating these? Just general cleanup?

"""A wrapper for unittest.TestCase that includes cleanup operations."""
@classmethod
def setUpClass(cls):
cls._cm = _cleanup_cm().__enter__()

@classmethod
def tearDownClass(cls):
cls._cm.__exit__(None, None, None)


def cleanup(style=None):
"""
A decorator to ensure that any global state is reset before
running a test.

Parameters
----------
style : str, dict, or list, optional
The style(s) to apply. Defaults to ``["classic",
"_classic_test_patch"]``.
"""

# If cleanup is used without arguments, *style* will be a callable, and we
# pass it directly to the wrapper generator. If cleanup if called with an
# argument, it is a string naming a style, and the function will be passed
# as an argument to what we return. This is a confusing, but somewhat
# standard, pattern for writing a decorator with optional arguments.

def make_cleanup(func):
if inspect.isgeneratorfunction(func):
@functools.wraps(func)
def wrapped_callable(*args, **kwargs):
with _cleanup_cm(), matplotlib.style.context(style):
yield from func(*args, **kwargs)
else:
@functools.wraps(func)
def wrapped_callable(*args, **kwargs):
with _cleanup_cm(), matplotlib.style.context(style):
func(*args, **kwargs)

return wrapped_callable

if callable(style):
result = make_cleanup(style)
# Default of mpl_test_settings fixture and image_comparison too.
style = ["classic", "_classic_test_patch"]
return result
else:
return make_cleanup


def check_freetype_version(ver):
if ver is None:
return True
Expand Down