FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
validators/tests/test_length.py at master · python-validators/validators · GitHub
python-validators
validators
Repository navigation
Code
Issues
6
(6)
Pull requests
34
(34)
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
validators
/
tests
/
test_length.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (19 loc) · 853 Bytes
Breadcrumbs
validators
/
tests
/
test_length.py
Copy path
File metadata and controls
25 lines (19 loc) · 853 Bytes
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
"""Test Length."""
# external
import
pytest
# local
from
validators
import
ValidationError
,
length
@
pytest
.
mark
.
parametrize
(
(
"value"
,
"min_val"
,
"max_val"
),
[(
"password"
,
2
,
None
), (
"password"
,
None
,
None
), (
"password"
,
0
,
10
), (
"password"
,
8
,
8
)],
)
def
test_returns_true_on_valid_length
(
value
:
str
,
min_val
:
int
,
max_val
:
int
):
"""Test returns true on valid length."""
assert
length
(
value
,
min_val
=
min_val
,
max_val
=
max_val
)
@
pytest
.
mark
.
parametrize
(
(
"value"
,
"min_val"
,
"max_val"
),
[(
"something"
,
14
,
12
), (
"something"
,
-
10
,
-
20
), (
"something"
,
0
,
-
2
), (
"something"
,
13
,
14
)],
)
def
test_returns_failed_validation_on_invalid_range
(
value
:
str
,
min_val
:
int
,
max_val
:
int
):
"""Test returns failed validation on invalid range."""
assert
isinstance
(
length
(
value
,
min_val
=
min_val
,
max_val
=
max_val
),
ValidationError
)
Back
|
FazBrowse Home
|
New Git URL