How to use the deal.cases function in deal

To help you get started, we’ve selected a few deal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github life4 / deal / tests.py View on Github external
def test_return_type_checks(self):
        def div(a: int, b: int):
            return 1

        for case in deal.cases(div, count=20):
            case()

        def div(a: int, b: int) -> str:
            return 1

        with pytest.raises(TypeError):
            case = next(iter(deal.cases(div, count=20)))
            case()
github life4 / deal / tests.py View on Github external
def test_params_detected(self):
        for case in deal.cases(self.func, count=10):
            assert set(case.kwargs) == {'a', 'b'}
github life4 / deal / tests.py View on Github external
def test_count(self):
        for count in (1, 10, 20, 50):
            cases = deal.cases(self.func, count=count)
            assert len(list(cases)) == count
github life4 / deal / tests / test_case.py View on Github external
def test_params_type():
    for case in deal.cases(func, count=10):
        assert type(case.kwargs['a']) is int
        assert type(case.kwargs['b']) is int
github life4 / deal / tests.py View on Github external
def test_params_ok_with_excs(self):
        results = []
        for case in deal.cases(self.func, count=20):
            result = case()
            results.append(result)
        assert any(r is not NoReturn for r in results), 'exception occured on every run'
        assert any(r is NoReturn for r in results), 'no exception occured'
github life4 / deal / tests / test_case.py View on Github external
def test_explicit_kwargs():
    def div(a: int, b: int):
        assert b == 4

    for case in deal.cases(div, kwargs=dict(b=4), count=20):
        case()
github life4 / deal / tests / test_case.py View on Github external
def test_params_ok_with_excs():
    results = []
    for case in deal.cases(func, count=20):
        result = case()
        results.append(result)
    assert any(r is NoReturn for r in results), 'no exception occured'
github life4 / deal / tests.py View on Github external
def test_return_type_checks(self):
        def div(a: int, b: int):
            return 1

        for case in deal.cases(div, count=20):
            case()

        def div(a: int, b: int) -> str:
            return 1

        with pytest.raises(TypeError):
            case = next(iter(deal.cases(div, count=20)))
            case()
github life4 / deal / examples / concat.py View on Github external
@pytest.mark.parametrize('case', deal.cases(concat))
def test_concat(case):
    case()