Exemplo n.º 1
0
def skip_if(condition):
    '''
    Given a boolean or function returning a boolean,
    if True the tests in this group will be skipped.
    '''
    # If necessary, turn boolean into function
    if type(condition) == bool:
        value = condition
        condition = lambda: value

    previous = _skip_condition.value

    def new_condition():
        return previous() or condition()

    with dynamic_bind(_skip_condition, new_condition):
        yield
Exemplo n.º 2
0
def scale(maximum):
    with dynamic_bind(_accumulated_score, Score(0,0)):
        yield
        score = _current_score()

    _accumulated_score.value = _accumulated_score.value + score.rescale(maximum)
Exemplo n.º 3
0
def keep_score():
    with dynamic_bind(_accumulated_score, Score(0,0)), cumulative():
        yield _current_score
Exemplo n.º 4
0
def active_reference_implementation_from_id(identifier):
    with dynamic_bind(_active_reference_implementation,
                      fetch_reference_implementation(identifier)):
        yield
Exemplo n.º 5
0
def active_reference_implementation(implementation):
    with dynamic_bind(_active_reference_implementation, implementation):
        yield
Exemplo n.º 6
0
def reference_module(module):
    with dynamic_bind(_reference_module, module):
        yield
Exemplo n.º 7
0
def context(key, value):
    new_context = {**_context.value, key: value}

    with dynamic_bind(_context, new_context):
        yield
Exemplo n.º 8
0
def reporting(on_pass=_do_nothing, on_fail=_do_nothing, on_skip=_do_nothing):
    with dynamic_bind(_context, {}), observers(on_pass=on_pass,
                                               on_fail=on_fail,
                                               on_skip=on_skip):
        yield
Exemplo n.º 9
0
def active_tested_implementation_from_id(identifier):
    tested_implementation = fetch_tested_implementation(identifier)

    with dynamic_bind(_active_tested_implementation, tested_implementation), dynamic_bind(_active_tested_implementation_id, identifier), skip_unless(bool(tested_implementation)):
        yield
Exemplo n.º 10
0
def active_tested_implementation(implementation):
    with dynamic_bind(_active_tested_implementation, implementation):
        yield
Exemplo n.º 11
0
def tested_module(module):
    with dynamic_bind(_tested_module, module):
        yield