def test_characters_of_specific_groups():
    st = characters(whitelist_categories=("Lu", "Nd"))

    find_any(st, lambda c: unicodedata.category(c) == "Lu")
    find_any(st, lambda c: unicodedata.category(c) == "Nd")

    assert_no_examples(st, lambda c: unicodedata.category(c) not in ("Lu", "Nd"))
def test_exclude_characters_of_specific_groups():
    st = characters(blacklist_categories=("Lu", "Nd"))

    find_any(st, lambda c: unicodedata.category(c) != "Lu")
    find_any(st, lambda c: unicodedata.category(c) != "Nd")

    assert_no_examples(st, lambda c: unicodedata.category(c) in ("Lu", "Nd"))
def test_exclude_characters_of_specific_groups():
    st = characters(blacklist_categories=("Lu", "Nd"))

    find_any(st, lambda c: unicodedata.category(c) != "Lu")
    find_any(st, lambda c: unicodedata.category(c) != "Nd")

    assert_no_examples(st, lambda c: unicodedata.category(c) in ("Lu", "Nd"))
def test_exclude_characters_of_specific_groups():
    st = characters(blacklist_categories=('Lu', 'Nd'))

    find(st, lambda c: unicodedata.category(c) != 'Lu')
    find(st, lambda c: unicodedata.category(c) != 'Nd')

    assert_no_examples(st, lambda c: unicodedata.category(c) in ('Lu', 'Nd'))
def test_exclude_characters_of_specific_groups():
    st = characters(blacklist_categories=('Lu', 'Nd'))

    find(st, lambda c: unicodedata.category(c) != 'Lu')
    find(st, lambda c: unicodedata.category(c) != 'Nd')

    assert_no_examples(st, lambda c: unicodedata.category(c) in ('Lu', 'Nd'))
def test_blacklisted_characters():
    bad_chars = u'te02тест49st'
    st = characters(min_codepoint=ord('0'), max_codepoint=ord('9'),
                    blacklist_characters=bad_chars)

    assert '1' == find(st, lambda c: True)

    assert_no_examples(st, lambda c: c in bad_chars)
def test_characters_of_specific_groups():
    st = characters(whitelist_categories=('Lu', 'Nd'))

    find(st, lambda c: unicodedata.category(c) == 'Lu')
    find(st, lambda c: unicodedata.category(c) == 'Nd')

    assert_no_examples(
        st, lambda c: unicodedata.category(c) not in ('Lu', 'Nd'))
def test_characters_of_specific_groups():
    st = characters(whitelist_categories=('Lu', 'Nd'))

    find(st, lambda c: unicodedata.category(c) == 'Lu')
    find(st, lambda c: unicodedata.category(c) == 'Nd')

    assert_no_examples(st, lambda c: unicodedata.category(c) not in
                       ('Lu', 'Nd'))
示例#9
0
def test_allow_subnormal_defaults_correctly(kwargs):
    allow_subnormal = kwargs.pop("allow_subnormal")
    strat = floats(**kwargs).filter(lambda x: x != 0)
    if allow_subnormal:
        find_any(strat, lambda x: -float_info.min < x < float_info.min)
    else:
        assert_no_examples(strat,
                           lambda x: -float_info.min < x < float_info.min)
示例#10
0
def test_characters_of_specific_groups():
    st = characters(whitelist_categories=("Lu", "Nd"))

    find_any(st, lambda c: unicodedata.category(c) == "Lu")
    find_any(st, lambda c: unicodedata.category(c) == "Nd")

    assert_no_examples(st, lambda c: unicodedata.category(c) not in
                       ("Lu", "Nd"))
示例#11
0
def test_subnormal_generation(xp, xps, kwargs):
    """Generation of subnormals is dependent on FTZ behaviour of array module."""
    strat = xps.from_dtype(xp.float32, **kwargs).filter(lambda n: n != 0)
    if flushes_to_zero(xp, width=32):
        assert_no_examples(strat,
                           lambda n: -smallest_normal < n < smallest_normal)
    else:
        find_any(strat, lambda n: -smallest_normal < n < smallest_normal)
def test_whitelist_characters_disjoint_blacklist_characters():
    good_chars = u'123abc'
    bad_chars = u'456def'
    st = characters(min_codepoint=ord('0'), max_codepoint=ord('9'),
                    blacklist_characters=bad_chars,
                    whitelist_characters=good_chars)

    assert_no_examples(st, lambda c: c in bad_chars)
def test_whitelisted_characters_override():
    good_characters = u'teтестst'
    st = characters(min_codepoint=ord('0'), max_codepoint=ord('9'),
                    whitelist_characters=good_characters)

    find_any(st, lambda c: c in good_characters)
    find_any(st, lambda c: c in '0123456789')

    assert_no_examples(st, lambda c: c not in good_characters + '0123456789')
def test_blacklisted_characters():
    bad_chars = u"te02тест49st"
    st = characters(
        min_codepoint=ord("0"), max_codepoint=ord("9"), blacklist_characters=bad_chars
    )

    assert "1" == minimal(st, lambda c: True)

    assert_no_examples(st, lambda c: c in bad_chars)
def test_whitelist_characters_disjoint_blacklist_characters():
    good_chars = u'123abc'
    bad_chars = u'456def'
    st = characters(min_codepoint=ord('0'),
                    max_codepoint=ord('9'),
                    blacklist_characters=bad_chars,
                    whitelist_characters=good_chars)

    assert_no_examples(st, lambda c: c in bad_chars)
def test_blacklisted_characters():
    bad_chars = u'te02тест49st'
    st = characters(min_codepoint=ord('0'),
                    max_codepoint=ord('9'),
                    blacklist_characters=bad_chars)

    assert '1' == find(st, lambda c: True)

    assert_no_examples(st, lambda c: c in bad_chars)
示例#17
0
def test_blacklisted_characters():
    bad_chars = "te02тест49st"
    st = characters(min_codepoint=ord("0"),
                    max_codepoint=ord("9"),
                    blacklist_characters=bad_chars)

    assert "1" == minimal(st, lambda c: True)

    assert_no_examples(st, lambda c: c in bad_chars)
示例#18
0
def test_subpattern_flags():
    strategy = st.from_regex(u'(?i)a(?-i:b)')

    # "a" is case insensitive
    find_any(strategy, lambda s: s[0] == u'a')
    find_any(strategy, lambda s: s[0] == u'A')
    # "b" is case sensitive
    find_any(strategy, lambda s: s[1] == u'b')

    assert_no_examples(strategy, lambda s: s[1] == u'B')
示例#19
0
def test_subpattern_flags():
    strategy = st.from_regex(u'(?i)a(?-i:b)')

    # "a" is case insensitive
    find_any(strategy, lambda s: s[0] == u'a')
    find_any(strategy, lambda s: s[0] == u'A')
    # "b" is case sensitive
    find_any(strategy, lambda s: s[1] == u'b')

    assert_no_examples(strategy, lambda s: s[1] == u'B')
示例#20
0
def test_subpattern_flags():
    strategy = st.from_regex("(?i)\\Aa(?-i:b)\\Z")

    # "a" is case insensitive
    find_any(strategy, lambda s: s[0] == "a")
    find_any(strategy, lambda s: s[0] == "A")
    # "b" is case sensitive
    find_any(strategy, lambda s: s[1] == "b")

    assert_no_examples(strategy, lambda s: s[1] == "B")
def test_subpattern_flags():
    strategy = st.from_regex(u"(?i)\\Aa(?-i:b)\\Z")

    # "a" is case insensitive
    find_any(strategy, lambda s: s[0] == u"a")
    find_any(strategy, lambda s: s[0] == u"A")
    # "b" is case sensitive
    find_any(strategy, lambda s: s[1] == u"b")

    assert_no_examples(strategy, lambda s: s[1] == u"B")
def test_whitelisted_characters_override():
    good_characters = u'teтестst'
    st = characters(min_codepoint=ord('0'),
                    max_codepoint=ord('9'),
                    whitelist_characters=good_characters)

    find_any(st, lambda c: c in good_characters)
    find_any(st, lambda c: c in '0123456789')

    assert_no_examples(st, lambda c: c not in good_characters + '0123456789')
def test_whitelist_characters_disjoint_blacklist_characters():
    good_chars = u"123abc"
    bad_chars = u"456def"
    st = characters(
        min_codepoint=ord("0"),
        max_codepoint=ord("9"),
        blacklist_characters=bad_chars,
        whitelist_characters=good_chars,
    )

    assert_no_examples(st, lambda c: c in bad_chars)
示例#24
0
def test_whitelist_characters_disjoint_blacklist_characters():
    good_chars = "123abc"
    bad_chars = "456def"
    st = characters(
        min_codepoint=ord("0"),
        max_codepoint=ord("9"),
        blacklist_characters=bad_chars,
        whitelist_characters=good_chars,
    )

    assert_no_examples(st, lambda c: c in bad_chars)
示例#25
0
def test_whitelisted_characters_override():
    good_characters = "teтестst"
    st = characters(
        min_codepoint=ord("0"),
        max_codepoint=ord("9"),
        whitelist_characters=good_characters,
    )

    find_any(st, lambda c: c in good_characters)
    find_any(st, lambda c: c in "0123456789")

    assert_no_examples(st, lambda c: c not in good_characters + "0123456789")
def test_whitelisted_characters_override():
    good_characters = u"teтестst"
    st = characters(
        min_codepoint=ord("0"),
        max_codepoint=ord("9"),
        whitelist_characters=good_characters,
    )

    find_any(st, lambda c: c in good_characters)
    find_any(st, lambda c: c in "0123456789")

    assert_no_examples(st, lambda c: c not in good_characters + "0123456789")
示例#27
0
def test_caret_in_the_middle_does_not_generate_anything():
    r = re.compile("a^b")

    assert_no_examples(st.from_regex(r))
示例#28
0
def test_exclude_characters_of_major_categories():
    st = characters(blacklist_categories=("L", "N"))
    find_any(st, lambda c: not unicodedata.category(c).startswith("L"))
    find_any(st, lambda c: not unicodedata.category(c).startswith("N"))
    assert_no_examples(st, lambda c: unicodedata.category(c)[0] in ("L", "N"))
示例#29
0
def test_assume_in_just_raises_immediately():
    assert_no_examples(st.just(1).map(lambda x: assume(x == 2)))
示例#30
0
def test_no_examples():
    assert_no_examples(st.nothing())
示例#31
0
def test_negative_lookahead():
    # no efficient support
    strategy = st.from_regex("^ab(?!cd)[abcd]*")

    assert_all_examples(strategy, lambda s: not s.startswith("abcd"))
    assert_no_examples(strategy, lambda s: s.startswith("abcd"))
示例#32
0
def test_one_of_empty():
    e = st.one_of()
    assert e.is_empty
    assert_no_examples(e)
def test_self_tuple_draws_nothing():
    x = st.deferred(lambda: st.tuples(x))
    assert_no_examples(x)
def test_self_recursive_flatmap():
    bad = st.deferred(lambda: bad.flatmap(lambda x: st.none()))
    assert_no_examples(bad)
def test_hidden_self_references_just_result_in_no_example():
    bad = st.deferred(lambda: st.none().flatmap(lambda _: bad))
    assert_no_examples(bad)
def test_self_recursive_flatmap():
    bad = st.deferred(lambda: bad.flatmap(lambda x: st.none()))
    assert_no_examples(bad)
def test_self_tuple_draws_nothing():
    x = st.deferred(lambda: st.tuples(x))
    assert_no_examples(x)
def test_mutually_recursive_tuples_draw_nothing():
    x = st.deferred(lambda: st.tuples(y))
    y = st.tuples(x)

    assert_no_examples(x)
    assert_no_examples(y)
def test_find_something_rare():
    st = characters(whitelist_categories=['Zs'], min_codepoint=12288)

    find(st, lambda c: unicodedata.category(c) == 'Zs')

    assert_no_examples(st, lambda c: unicodedata.category(c) != 'Zs')
示例#40
0
def test_impossible_negative_lookahead():
    assert_no_examples(st.from_regex("(?!foo)foo"))
def test_hidden_self_references_just_result_in_no_example():
    bad = st.deferred(lambda: st.none().flatmap(lambda _: bad))
    assert_no_examples(bad)
示例#42
0
def test_negative_lookbehind():
    # no efficient support
    strategy = st.from_regex("[abc]*(?<!abc)d")

    assert_all_examples(strategy, lambda s: not s.endswith("abcd"))
    assert_no_examples(strategy, lambda s: s.endswith("abcd"))
示例#43
0
def test_no_nil_uuid_by_default():
    assert_no_examples(st.uuids(), lambda x: x == uuid.UUID(int=0))
def test_find_something_rare():
    st = characters(whitelist_categories=['Zs'], min_codepoint=12288)

    find(st, lambda c: unicodedata.category(c) == 'Zs')

    assert_no_examples(st, lambda c: unicodedata.category(c) != 'Zs')
示例#45
0
def test_one_of_empty():
    e = st.one_of()
    assert e.is_empty
    assert_no_examples(e)
示例#46
0
def test_subsequence_of_empty():
    sub_seq_strat = st.lists(st.none(), max_size=0)
    assert_no_examples(sub_seq_strat)
示例#47
0
def test_no_examples():
    assert_no_examples(st.nothing())
示例#48
0
def test_example_raises_unsatisfiable_when_too_filtered():
    assert_no_examples(integers().filter(lambda x: False))
示例#49
0
def test_assume_in_just_raises_immediately():
    assert_no_examples(st.just(1).map(lambda x: assume(x == 2)))
def test_mutually_recursive_tuples_draw_nothing():
    x = st.deferred(lambda: st.tuples(y))
    y = st.tuples(x)

    assert_no_examples(x)
    assert_no_examples(y)
示例#51
0
def test_caret_in_the_middle_does_not_generate_anything():
    r = re.compile(u'a^b')

    assert_no_examples(st.from_regex(r))
示例#52
0
def test_impossible_negative_lookahead():
    assert_no_examples(st.from_regex(u'(?!foo)foo'))
def test_exclude_characters_of_major_categories():
    st = characters(blacklist_categories=("L", "N"))
    find_any(st, lambda c: not unicodedata.category(c).startswith("L"))
    find_any(st, lambda c: not unicodedata.category(c).startswith("N"))
    assert_no_examples(st, lambda c: unicodedata.category(c)[0] in ("L", "N"))
示例#54
0
def test_negative_lookbehind():
    # no efficient support
    strategy = st.from_regex(u'[abc]*(?<!abc)d')

    assert_all_examples(strategy, lambda s: not s.endswith(u'abcd'))
    assert_no_examples(strategy, lambda s: s.endswith(u'abcd'))
示例#55
0
def test_negative_lookahead():
    # no efficient support
    strategy = st.from_regex(u'^ab(?!cd)[abcd]*')

    assert_all_examples(strategy, lambda s: not s.startswith(u'abcd'))
    assert_no_examples(strategy, lambda s: s.startswith(u'abcd'))
def test_example_raises_unsatisfiable_when_too_filtered():
    assert_no_examples(integers().filter(lambda x: False))
def test_characters_of_major_categories():
    st = characters(whitelist_categories=('L', 'N'))
    find_any(st, lambda c: unicodedata.category(c).startswith('L'))
    find_any(st, lambda c: unicodedata.category(c).startswith('N'))
    assert_no_examples(
        st, lambda c: unicodedata.category(c)[0] not in ('L', 'N'))