コード例 #1
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"))
コード例 #2
0
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"))
コード例 #3
0
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"))
コード例 #4
0
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'))
コード例 #5
0
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'))
コード例 #6
0
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)
コード例 #7
0
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'))
コード例 #8
0
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
ファイル: test_from_dtype.py プロジェクト: jjpal/hypothesis
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)
コード例 #12
0
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)
コード例 #13
0
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')
コード例 #14
0
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)
コード例 #15
0
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)
コード例 #16
0
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
ファイル: test_regex.py プロジェクト: rboulton/hypothesis
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
ファイル: test_regex.py プロジェクト: soutys/hypothesis
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")
コード例 #21
0
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")
コード例 #22
0
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')
コード例 #23
0
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")
コード例 #26
0
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
ファイル: test_regex.py プロジェクト: soutys/hypothesis
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
ファイル: test_regex.py プロジェクト: soutys/hypothesis
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
ファイル: test_one_of.py プロジェクト: uchchwhash/hypothesis
def test_one_of_empty():
    e = st.one_of()
    assert e.is_empty
    assert_no_examples(e)
コード例 #33
0
def test_self_tuple_draws_nothing():
    x = st.deferred(lambda: st.tuples(x))
    assert_no_examples(x)
コード例 #34
0
def test_self_recursive_flatmap():
    bad = st.deferred(lambda: bad.flatmap(lambda x: st.none()))
    assert_no_examples(bad)
コード例 #35
0
def test_hidden_self_references_just_result_in_no_example():
    bad = st.deferred(lambda: st.none().flatmap(lambda _: bad))
    assert_no_examples(bad)
コード例 #36
0
def test_self_recursive_flatmap():
    bad = st.deferred(lambda: bad.flatmap(lambda x: st.none()))
    assert_no_examples(bad)
コード例 #37
0
def test_self_tuple_draws_nothing():
    x = st.deferred(lambda: st.tuples(x))
    assert_no_examples(x)
コード例 #38
0
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)
コード例 #39
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')
コード例 #40
0
ファイル: test_regex.py プロジェクト: soutys/hypothesis
def test_impossible_negative_lookahead():
    assert_no_examples(st.from_regex("(?!foo)foo"))
コード例 #41
0
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
ファイル: test_regex.py プロジェクト: soutys/hypothesis
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
ファイル: test_uuids.py プロジェクト: jjpal/hypothesis
def test_no_nil_uuid_by_default():
    assert_no_examples(st.uuids(), lambda x: x == uuid.UUID(int=0))
コード例 #44
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
ファイル: test_map.py プロジェクト: Wilfred/hypothesis-python
def test_assume_in_just_raises_immediately():
    assert_no_examples(st.just(1).map(lambda x: assume(x == 2)))
コード例 #50
0
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
ファイル: test_regex.py プロジェクト: rboulton/hypothesis
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
ファイル: test_regex.py プロジェクト: rboulton/hypothesis
def test_impossible_negative_lookahead():
    assert_no_examples(st.from_regex(u'(?!foo)foo'))
コード例 #53
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"))
コード例 #54
0
ファイル: test_regex.py プロジェクト: rboulton/hypothesis
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
ファイル: test_regex.py プロジェクト: rboulton/hypothesis
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'))
コード例 #56
0
def test_example_raises_unsatisfiable_when_too_filtered():
    assert_no_examples(integers().filter(lambda x: False))
コード例 #57
0
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'))