def test_collection_equal_does_not_accept_collection_lhs_with_incompatible_types(lhs, rhs):
    with pytest.raises(LeftHandSideTypeError) as e:
        Collection(rhs).equal(lhs)

    assert (
            '[Collection.equal] Could not apply left-hand side <list> ([…]) to right-hand side <list> ([…]). '
            'Collections have incompatible types.' in str(e.value)
    )
def test_collection_rhs_does_not_match_collection_lhs(lhs, rhs):
    assert Collection(rhs).match(lhs) is False
def test_empty_collection_rhs_is_equal_to_none_lhs():
    assert Collection([]).equal(None) is True
def test_collection_rhs_matches_collection_lhs(lhs, rhs):
    assert Collection(rhs).match(lhs) is True
def test_collection_rhs_is_not_equal_to_collection_lhs(lhs, rhs):
    assert Collection(rhs).equal(lhs) is False
def test_collection_contains_does_not_accept_scalar_lhs_with_incompatible_types(lhs, rhs):
    with pytest.raises(LeftHandSideTypeError) as e:
        Collection(rhs).contains(lhs)

    assert '[Collection.contains] Could not apply left-hand side' in str(e.value)
    assert 'Left-hand side is not compatible with collection type.' in str(e.value)
def test_collection_contains_does_not_accept_invalid_lhs(lhs, rhs):
    with pytest.raises(LeftHandSideTypeError) as e:
        Collection(rhs).contains(lhs)

    assert '[Collection.contains] Could not apply left-hand side <{}>'.format(type(lhs).__name__) in str(e.value)
def test_collection_match_does_not_accept_collection_lhs_with_incompatible_types(lhs, rhs):
    with pytest.raises(LeftHandSideTypeError) as e:
        Collection(rhs).match(lhs)

    assert '[Collection.match] Could not apply left-hand side' in str(e.value)
    assert 'Collections have incompatible types.' in str(e.value)
def test_non_empty_collection_rhs_does_not_match_none_lhs():
    assert Collection([1, 2, 3]).match(None) is False
def test_non_empty_collection_rhs_is_not_equal_to_none_lhs():
    assert Collection([1, 2, 3]).equal(None) is False
def test_collection_equal_does_not_accept_scalar_lhs(lhs, rhs):
    with pytest.raises(LeftHandSideTypeError) as e:
        Collection(rhs).equal(lhs)

    assert '[Collection.equal] Could not apply left-hand side <{}>'.format(type(lhs).__name__) in str(e.value)
def test_collection_does_not_accept_invalid_rhs(rhs):
    with pytest.raises(RightHandSideTypeError) as e:
        Collection(rhs)

    assert '[Collection] Invalid right-hand side <{}>'.format(type(rhs).__name__) in str(e.value)
def test_collection_rhs_does_not_contain_scalar_lhs(lhs, rhs):
    assert Collection(rhs).contains(lhs) is False
def test_empty_collection_rhs_matches_none_lhs():
    assert Collection([]).match(None) is True
def test_collection_rhs_contains_scalar_lhs(lhs, rhs):
    assert Collection(rhs).contains(lhs) is True