Exemplo n.º 1
0
def test_returns_all_child_strategies_from_list():
    strat = ss.SearchStrategies().strategy([int,[str,float]])

    children = [s.descriptor for s in strat.all_child_strategies()]
    
    assert int in children
    assert str in children
    assert float in children
    assert [str, float] in children
Exemplo n.º 2
0
def strategy(*args,**kwargs):
    return ss.SearchStrategies().strategy(*args,**kwargs)
Exemplo n.º 3
0
def test_returns_no_duplicate_child_strategies():
    strat = ss.SearchStrategies().strategy([int,[int,float]])
    children = [s.descriptor for s in strat.all_child_strategies()]
    assert len([x for x in children if x == int]) == 1
Exemplo n.º 4
0
def test_strategy_repr_handles_instances_without_dicts():
    strats = ss.SearchStrategies()
    strats.define_specification_for_instances(int, TrivialStrategy)
    
    assert repr(strats.strategy(42)) == "TrivialStrategy(42)"
Exemplo n.º 5
0
def test_strategy_repr_handles_custom_types():
    assert "X(x=str)" in repr(ss.SearchStrategies().strategy(X(str)))