]) def test_valid_member_of(obj, value, expected): assert rlz.member_of(obj, value) == expected @pytest.mark.parametrize(('obj', 'value', 'expected'), [(Foo, 'c', IbisTypeError), (Bar, 'c', IbisTypeError), (Baz(3), 'b', IbisTypeError)]) def test_invalid_member_of(obj, value, expected): with pytest.raises(expected): rlz.member_of(obj, value) @pytest.mark.parametrize( ('validator', 'values', 'expected'), [(rlz.list_of(identity), (3, 2), ibis.sequence([3, 2])), (rlz.list_of(rlz.integer), (3, 2), ibis.sequence([3, 2])), (rlz.list_of(rlz.integer), (3, None), ibis.sequence([3, ibis.NA])), (rlz.list_of(rlz.string), ('a', ), ibis.sequence(['a'])), (rlz.list_of(rlz.string), ['a', 'b'], ibis.sequence(['a', 'b'])), pytest.param( rlz.list_of(rlz.list_of(rlz.string)), [[], ['a']], ibis.sequence([[], ['a']]), marks=pytest.mark.xfail(raises=ValueError, reason='Not yet implemented'), ), (rlz.list_of(rlz.boolean, min_length=2), [True, False], ibis.sequence([True, False]))]) def test_valid_list_of(validator, values, expected): result = validator(values)
(Bar, 'c', IbisTypeError), (Baz(3), 'b', IbisTypeError), ], ) def test_invalid_member_of(obj, value, expected): with pytest.raises(expected): rlz.member_of(obj, value) @pytest.mark.parametrize( ('validator', 'values', 'expected'), [ param( rlz.value_list_of(identity), (3, 2), ibis.sequence([3, 2]), id="list_identity", ), param( rlz.value_list_of(rlz.integer), (3, 2), ibis.sequence([3, 2]), id="list_int", ), param( rlz.value_list_of(rlz.integer), (3, None), ibis.sequence([3, ibis.NA]), id="list_int_null", ), param(
('obj', 'value', 'expected'), [ (Foo, 'c', IbisTypeError), (Bar, 'c', IbisTypeError), (Baz(3), 'b', IbisTypeError), ], ) def test_invalid_member_of(obj, value, expected): with pytest.raises(expected): rlz.member_of(obj, value) @pytest.mark.parametrize( ('validator', 'values', 'expected'), [ (rlz.list_of(identity), (3, 2), ibis.sequence([3, 2])), (rlz.list_of(rlz.integer), (3, 2), ibis.sequence([3, 2])), (rlz.list_of(rlz.integer), (3, None), ibis.sequence([3, ibis.NA])), (rlz.list_of(rlz.string), ('a',), ibis.sequence(['a'])), (rlz.list_of(rlz.string), ['a', 'b'], ibis.sequence(['a', 'b'])), pytest.param( rlz.list_of(rlz.list_of(rlz.string)), [[], ['a']], ibis.sequence([[], ['a']]), marks=pytest.mark.xfail( raises=ValueError, reason='Not yet implemented' ), ), ( rlz.list_of(rlz.boolean, min_length=2), [True, False],
]) def test_valid_member_of(obj, value, expected): assert rlz.member_of(obj, value) == expected @pytest.mark.parametrize(('obj', 'value', 'expected'), [(Foo, 'c', IbisTypeError), (Bar, 'c', IbisTypeError), (Baz(3), 'b', IbisTypeError)]) def test_invalid_member_of(obj, value, expected): with pytest.raises(expected): rlz.member_of(obj, value) @pytest.mark.parametrize( ('validator', 'values', 'expected'), [(rlz.list_of(identity), 3, ibis.sequence([3])), (rlz.list_of(identity), (3, 2), ibis.sequence([3, 2])), (rlz.list_of(rlz.integer), (3, 2), ibis.sequence([3, 2])), (rlz.list_of(rlz.integer), (3, None), ibis.sequence([3, ibis.NA])), (rlz.list_of(rlz.string), 'asd', ibis.sequence(['asd'])), (rlz.list_of(rlz.boolean, min_length=2), [True, False], ibis.sequence([True, False]))]) def test_valid_list_of(validator, values, expected): result = validator(values) assert result.equals(expected) @pytest.mark.parametrize(('validator', 'values', 'expected'), [ (rlz.list_of(rlz.double, min_length=2), [1], IbisTypeError), (rlz.list_of(rlz.integer), 1.1, IbisTypeError), ])
('obj', 'value', 'expected'), [ (Foo, 'c', IbisTypeError), (Bar, 'c', IbisTypeError), (Baz(3), 'b', IbisTypeError), ], ) def test_invalid_member_of(obj, value, expected): with pytest.raises(expected): rlz.member_of(obj, value) @pytest.mark.parametrize( ('validator', 'values', 'expected'), [ (rlz.value_list_of(identity), (3, 2), ibis.sequence([3, 2])), (rlz.value_list_of(rlz.integer), (3, 2), ibis.sequence([3, 2])), ( rlz.value_list_of(rlz.integer), (3, None), ibis.sequence([3, ibis.NA]), ), (rlz.value_list_of(rlz.string), ('a', ), ibis.sequence(['a'])), (rlz.value_list_of(rlz.string), ['a', 'b'], ibis.sequence(['a', 'b'])), pytest.param( rlz.value_list_of(rlz.value_list_of(rlz.string)), [[], ['a']], ibis.sequence([[], ['a']]), marks=pytest.mark.xfail(raises=ValueError, reason='Not yet implemented'), ),