Passed
Pull Request — master (#259)
by Piotr
01:50
created

catch_signal()   A

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
1
from contextlib import contextmanager
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
try:
4
    from unittest import mock
5
except ImportError:
6
    import mock
7
8
9
@contextmanager
10
def catch_signal(signal):
11
    """Catch django signal and return the mocked call."""
12
    handler = mock.Mock()
13
    signal.connect(handler)
14
    yield handler
15
    signal.disconnect(handler)
16