Failed Conditions
Pull Request — master (#1182)
by Lasse
02:00 queued 25s
created

bears.tests.skip_bear_test()   A

Complexity

Conditions 2

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 3
rs 10
1
from unittest.case import skip, skipIf
2
3
4
def generate_skip_decorator(bear):
5
    """
6
    Creates a skip decorator for a `unittest` module test from a bear.
7
8
    `check_prerequisites` is used to determine a test skip.
9
10
    :param bear: The bear whose prerequisites determine the test skip.
11
    :return:     A decorator that skips the test if appropriate.
12
    """
13
    result = bear.check_prerequisites()
14
15
    return skip(result) if isinstance(result, str) else skipIf(False, '')
16