def test_can_falsify_false_things_with_many_args(descs):
    assume(len(descs) > 0)
    assume(size(descs) <= MAX_SIZE)
    descs = tuple(descs)
    x = verifier.falsify(lambda *args: False, *descs)
    strategy = small_table.strategy(descs)
    assert not list(strategy.simplify(x))
def test_cannot_generate_mutable_data_from_an_immutable_strategy(d):
    strategy = small_table.strategy(d)
    assume(strategy.has_immutable_data)
    really_small_verifier = Verifier(
        settings=hs.Settings(max_examples=50, timeout=5))

    with pytest.raises((Unfalsifiable, Unsatisfiable)):
        print(nice_string(d),
              really_small_verifier.falsify(is_immutable_data, d))
Exemple #3
0
def test_can_not_save_as_incompatible_examples(dav, dav2):
    strategy = small_table.strategy(dav.descriptor)
    assume(not strategy.could_have_produced(dav2.value))
    ft = ConverterTable.default()
    try:
        converter = ft.specification_for(dav.descriptor)
    except NotSerializeable:
        assume(False)

    with pytest.raises(WrongFormat):
        converter.to_basic(dav2.value)
Exemple #4
0
def test_can_falsify_false_things(desc, random):
    assume(size(desc) <= MAX_SIZE)
    verifier.random = random
    x = verifier.falsify(lambda x: False, desc)[0]
    strategy = small_table.strategy(desc)
    assert not list(strategy.simplify(x))
Exemple #5
0
def test_can_minimize_descriptor_with_value(dav):
    s = small_table.strategy(DescriptorWithValue)
    list(s.simplify_such_that(dav, lambda x: True))
Exemple #6
0
def test_decomposing_produces_things_that_can_be_produced(dav):
    for d, v in small_table.strategy(dav.descriptor).decompose(dav.value):
        assert small_table.strategy(d).could_have_produced(v)
Exemple #7
0
def test_can_produce_what_it_produces(desc):
    strategy = small_table.strategy(desc)
    with pytest.raises(Unfalsifiable):
        verifier.falsify(strategy.could_have_produced, desc)
Exemple #8
0
def test_copies_all_its_values_correctly(desc, random):
    strategy = small_table.strategy(desc)
    value = strategy.produce(random, strategy.parameter.draw(random))
    assert actually_equal(value, strategy.copy(value))