/
test_argument_validation.py
71 lines (66 loc) · 2.93 KB
/
test_argument_validation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# coding=utf-8
#
# This file is part of Hypothesis, which may be found at
# https://github.com/HypothesisWorks/hypothesis-python
#
# Most of this work is copyright (C) 2013-2018 David R. MacIver
# (david@drmaciver.com), but it contains contributions by others. See
# CONTRIBUTING.rst for a full list of people who may hold copyright, and
# consult the git log if you need to determine who owns an individual
# contribution.
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.
#
# END HEADER
from __future__ import division, print_function, absolute_import
import hypothesis.strategies as st
import hypothesis.extra.pandas as pdst
from tests.common.arguments import e, argument_validation_test
BAD_ARGS = [
e(pdst.data_frames),
e(pdst.data_frames, pdst.columns(1, dtype='not a dtype')),
e(pdst.data_frames, pdst.columns(1, elements='not a strategy')),
e(pdst.data_frames, pdst.columns([[]])),
e(pdst.data_frames, [], index=[]),
e(pdst.data_frames, [], rows=st.fixed_dictionaries({'A': st.just(1)})),
e(pdst.data_frames, pdst.columns(1)),
e(pdst.data_frames, pdst.columns(1, dtype=float, fill=1)),
e(pdst.data_frames, pdst.columns(1, dtype=float, elements=1)),
e(pdst.data_frames, pdst.columns(1, fill=1, dtype=float)),
e(pdst.data_frames, pdst.columns(['A', 'A'], dtype=float)),
e(pdst.data_frames, pdst.columns(1, elements=st.none(), dtype=int)),
e(pdst.data_frames, 1),
e(pdst.data_frames, [1]),
e(pdst.data_frames, pdst.columns(1, dtype='category')),
e(pdst.data_frames,
pdst.columns(['A'], dtype=bool),
rows=st.tuples(st.booleans(), st.booleans())),
e(pdst.data_frames,
pdst.columns(1, elements=st.booleans()),
rows=st.tuples(st.booleans())),
e(pdst.data_frames, rows=st.integers(), index=pdst.range_indexes(0, 0)),
e(pdst.data_frames, rows=st.integers(), index=pdst.range_indexes(1, 1)),
e(pdst.data_frames, pdst.columns(1, dtype=int), rows=st.integers()),
e(pdst.indexes),
e(pdst.indexes, dtype='category'),
e(pdst.indexes, dtype='not a dtype'),
e(pdst.indexes, elements='not a strategy'),
e(pdst.indexes, elements=st.text(), dtype=float),
e(pdst.indexes, elements=st.none(), dtype=int),
e(pdst.indexes, dtype=int, max_size=0, min_size=1),
e(pdst.indexes, dtype=int, unique='true'),
e(pdst.indexes, dtype=int, min_size='0'),
e(pdst.indexes, dtype=int, max_size='1'),
e(pdst.range_indexes, 1, 0),
e(pdst.range_indexes, min_size='0'),
e(pdst.range_indexes, max_size='1'),
e(pdst.series),
e(pdst.series, dtype='not a dtype'),
e(pdst.series, elements='not a strategy'),
e(pdst.series, elements=st.none(), dtype=int),
e(pdst.series, dtype='category'),
e(pdst.series, index='not a strategy'),
]
test_raise_invalid_argument = argument_validation_test(BAD_ARGS)