コード例 #1
0
def test_cart_product_pytest():

    # simple
    names_lst, values = cart_product_pytest(('a', 'b'), ([True], [1, 2]))
    assert names_lst == ['a', 'b']
    assert values == [(True, 1), (True, 2)]

    # multi
    names_lst, values = cart_product_pytest(('a,b', 'c'),
                                            ([(True, 1)], [1, 2]))
    assert names_lst == ['a', 'b', 'c']
    assert values == [(True, 1, 1), (True, 1, 2)]

    # marks
    names_lst, values = cart_product_pytest(('a,b', 'c'),
                                            ([(True, 1)], [skip(1), 2]))
    assert names_lst == ['a', 'b', 'c']
    assert get_marked_parameter_values(values[0]) == (True, 1, 1)
    assert values[1] == (True, 1, 2)

    # lazy values
    def get_tuple():
        return 3, 4

    names_lst, values = cart_product_pytest(
        ('a', 'b,c'), ([True], [lazy_value(get_tuple, marks=skip), (1, 2)]))
    assert names_lst == ['a', 'b', 'c']
    assert values[0][0] is True
    assert is_lazy(values[0][1])
    assert is_lazy(values[0][2])
    assert values[0][1].get_id() == 'get_tuple[0]'
    assert values[0][2].get_id() == 'get_tuple[1]'
    assert values[1] == (True, 1, 2)
コード例 #2
0
ファイル: test_mlserver.py プロジェクト: cliveseldon/tempo-1
async def mlserver_runtime(model_settings: ModelSettings) -> InferenceRuntime:
    if is_lazy(model_settings):
        # NOTE: Some times pytest-cases may return a "LazyValue"
        model_settings = model_settings.get(request_or_item=mlserver_runtime)

    _runtime = InferenceRuntime(model_settings)
    await _runtime.load()

    return _runtime
コード例 #3
0
 def is_lazy_value_or_tupleitem_with_int_base(o):
     return is_lazy(o) and isinstance(o, int)