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

Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Add comment and docstring
  • Loading branch information
mdboom committed Nov 16, 2015
commit bfb0bb530bfe231de8765d4554bb94ba858814a4
17 changes: 17 additions & 0 deletions lib/matplotlib/testing/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ def tearDownClass(cls):


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

Parameters
----------
style : str, optional
The name of the style to apply.
"""

# 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.
Copy link
Member

Choose a reason for hiding this comment

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

Perfect! Very clear and helpful.


def make_cleanup(func):
@functools.wraps(func)
def wrapped_function(*args, **kwargs):
Expand Down