FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
validators/tests/test_between.py at master · python-validators/validators · GitHub
python-validators
validators
Repository navigation
Code
Issues
6
(6)
Pull requests
32
(32)
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
validators
/
tests
/
test_between.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
40 lines (32 loc) · 1.08 KB
Breadcrumbs
validators
/
tests
/
test_between.py
Copy path
File metadata and controls
40 lines (32 loc) · 1.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
"""Test Between."""
# standard
from
datetime
import
datetime
from
typing
import
TypeVar
# external
import
pytest
# local
from
validators
import
ValidationError
,
between
T
=
TypeVar
(
"T"
,
int
,
float
,
str
,
datetime
)
@
pytest
.
mark
.
parametrize
(
(
"value"
,
"min_val"
,
"max_val"
),
[(
12
,
11
,
13
), (
12
,
None
,
14
), (
12
,
11
,
None
), (
12
,
12
,
12
), (
0
,
0
,
0
), (
0
,
-
1
,
3
)],
)
def
test_returns_true_on_valid_range
(
value
:
T
,
min_val
:
T
,
max_val
:
T
):
"""Test returns true on valid range."""
assert
between
(
value
,
min_val
=
min_val
,
max_val
=
max_val
)
@
pytest
.
mark
.
parametrize
(
(
"value"
,
"min_val"
,
"max_val"
),
[
(
None
,
13
,
14
),
(
12
,
13
,
14
),
(
12
,
None
,
11
),
(
12
,
13
,
None
),
(
12
,
"13.5"
,
datetime
(
1970
,
1
,
1
)),
(
"12"
,
20.5
,
"None"
),
(
datetime
(
1970
,
1
,
1
),
20
,
"string"
),
(
30
,
40
,
"string"
),
],
)
def
test_returns_failed_validation_on_invalid_range
(
value
:
T
,
min_val
:
T
,
max_val
:
T
):
"""Test returns failed validation on invalid range."""
assert
isinstance
(
between
(
value
,
min_val
=
min_val
,
max_val
=
max_val
),
ValidationError
)
Back
|
FazBrowse Home
|
New Git URL