Beispiel #1
0
def test_copy_constructor():
    orig_words = Criteria()
    orig_words.begins_with('d').ends_with('n').contains('mna', 'tion')
    orig_words.contains_at(('t', 6), ('o', 8)).size_is(9)

    new_words = Criteria(orig_words)

    if orig_words.get_begins_with() != new_words.get_begins_with():
        assert False
    if orig_words.get_ends_with() != new_words.get_ends_with():
        assert False
    if Ct(orig_words.get_contains()) != Ct(new_words.get_contains()):
        assert False
    if Ct(orig_words.get_contains_at()) != Ct(new_words.get_contains_at()):
        assert False
    if orig_words.get_size() != new_words.get_size():
        assert False
Beispiel #2
0
def test_remove_contains():
    words1 = Criteria().contains('or', 'a', 'we', 'moo')
    exp_list = ['or']
    words1.remove_contains('we', 'a', 'moo')
    assert Ct(words1.get_contains()) == Ct(exp_list)
    words1.remove_contains('or')

    try:
        words1.remove_contains('nonexistent')
        assert False
    except CriteriaError:
        assert True
Beispiel #3
0
def test_contains():
    exp_list = ['or', 'we', 'a', 'moo']
    words1 = Criteria().contains('or', 'a', 'we')
    words1.contains('moo')
    assert Ct(words1.get_contains()) == Ct(exp_list)

    # add more failing cases
    Utils.set_disallowed_chars({'1', '2', '3'})
    try:
        Criteria().contains('a', 'B', '123')
        assert False
    except ArgumentError:
        assert True