コード例 #1
0
ファイル: test_testing.py プロジェクト: AABur/ward
def _(when=FALSY_PREDICATES):
    @skip(reason="reason", when=when)
    @testable_test
    def test_fn():
        assert True

    assert test_fn.ward_meta.marker == SkipMarker(reason="reason", when=when)
コード例 #2
0
ファイル: testing.py プロジェクト: darrenburns/ward
def skip(
    func_or_reason: Union[str, Callable, None] = None,
    *,
    reason: Optional[str] = None,
    when: Union[bool, Callable] = True,
):
    """
    Decorator which can be used to optionally skip tests.

    Args:
        func_or_reason (object): The wrapped test function to skip.
        reason: The reason the test was skipped. May appear in output.
        when: Predicate function. Will be called immediately before the test is executed.
            If it evaluates to True, the test will be skipped. Otherwise the test will run as normal.
    """
    if func_or_reason is None:
        return functools.partial(skip, reason=reason, when=when)

    if isinstance(func_or_reason, str):
        return functools.partial(skip, reason=func_or_reason, when=when)

    func = func_or_reason
    marker = SkipMarker(reason=reason, when=when)
    if hasattr(func, "ward_meta"):
        func.ward_meta.marker = marker  # type: ignore[attr-defined]
    else:
        func.ward_meta = CollectionMetadata(
            marker=marker)  # type: ignore[attr-defined]

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        return func(*args, **kwargs)

    return wrapper
コード例 #3
0
ファイル: test_testing.py プロジェクト: AABur/ward
def _(cache=cache, when=FALSY_PREDICATES):
    def test_fn():
        assert True

    t = Test(fn=test_fn, module_name=mod, marker=SkipMarker(when=when))
    result = t.run(cache)

    assert result == TestResult(t, outcome=TestOutcome.PASS)
コード例 #4
0
ファイル: test_testing.py プロジェクト: AABur/ward
def _():
    @skip
    @testable_test
    def test_fn():
        assert True

    assert test_fn.ward_meta.marker == SkipMarker()
    assert test_fn.ward_meta.marker.active
コード例 #5
0
ファイル: test_testing.py プロジェクト: AABur/ward
def _(cache=cache, when=FALSY_PREDICATES):
    def test_fn():
        assert 1 == 2

    t = Test(fn=test_fn, module_name=mod, marker=SkipMarker(when=when))
    result = t.run(cache)

    assert result.test == t
    assert result.outcome == TestOutcome.FAIL
コード例 #6
0
ファイル: testing.py プロジェクト: mkuyper/ward
def skip(func_or_reason=None, *, reason: str = None):
    if func_or_reason is None:
        return functools.partial(skip, reason=reason)

    if isinstance(func_or_reason, str):
        return functools.partial(skip, reason=func_or_reason)

    func = func_or_reason
    marker = SkipMarker(reason=reason)
    if hasattr(func, "ward_meta"):
        func.ward_meta.marker = marker
    else:
        func.ward_meta = WardMeta(marker=marker)

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        return func(*args, **kwargs)

    return wrapper
コード例 #7
0
ファイル: test_suite.py プロジェクト: darrenburns/ward
def skipped_test(module=module):
    @testable_test
    def t():
        assert 1 == 1

    return Test(fn=t, module_name=module, marker=SkipMarker())
コード例 #8
0
ファイル: test_suite.py プロジェクト: khusrokarim/ward
def skipped_test(module=module):
    return Test(fn=lambda: expect(1).equals(1),
                module_name=module,
                marker=SkipMarker())
コード例 #9
0
ファイル: test_testing.py プロジェクト: AABur/ward
def _(cache=cache, when=TRUTHY_PREDICATES):
    t = Test(fn=lambda: 1, module_name=mod, marker=SkipMarker(when=when))
    result = t.run(cache)
    assert result == TestResult(t, outcome=TestOutcome.SKIP)
コード例 #10
0
ファイル: test_models.py プロジェクト: gc-ss/ward
def _(when=FALSY_PREDICATES, ):
    skip_marker = SkipMarker(when=when)
    assert not skip_marker.active
コード例 #11
0
ファイル: test_models.py プロジェクト: gc-ss/ward
def _(when=TRUTHY_PREDICATES, ):
    skip_marker = SkipMarker(when=when)
    assert skip_marker.active
コード例 #12
0
def skipped_test(module=module):
    @testable_test
    def t():
        expect(1).equals(1)

    return Test(fn=t, module_name=module, marker=SkipMarker())