FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
validators/tests/test_length.py at master · pythonthings/validators · GitHub
pythonthings
validators
Repository navigation
Code
Pull requests
Actions
Projects
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
37 lines (30 loc) · 988 Bytes
Breadcrumbs
validators
/
tests
/
test_length.py
Copy path
File metadata and controls
37 lines (30 loc) · 988 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
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
import
pytest
import
validators
@
pytest
.
mark
.
parametrize
((
'value'
,
'min'
,
'max'
), [
(
'password'
,
2
,
10
),
(
'password'
,
None
,
10
),
(
'password'
,
2
,
None
),
(
'password'
,
8
,
8
)
])
def
test_returns_true_on_valid_length
(
value
,
min
,
max
):
assert
validators
.
length
(
value
,
min
=
min
,
max
=
max
)
@
pytest
.
mark
.
parametrize
((
'value'
,
'min'
,
'max'
), [
(
'something'
,
13
,
12
),
(
'something'
,
-
1
,
None
),
(
'something'
,
-
1
,
None
),
(
'something'
,
-
3
,
-
2
)
])
def
test_raises_assertion_error_for_invalid_args
(
value
,
min
,
max
):
with
pytest
.
raises
(
AssertionError
):
assert
validators
.
length
(
value
,
min
=
min
,
max
=
max
)
@
pytest
.
mark
.
parametrize
((
'value'
,
'min'
,
'max'
), [
(
'something'
,
13
,
14
),
(
'something'
,
None
,
6
),
(
'something'
,
13
,
None
)
])
def
test_returns_failed_validation_on_invalid_range
(
value
,
min
,
max
):
assert
isinstance
(
validators
.
length
(
value
,
min
=
min
,
max
=
max
),
validators
.
ValidationFailure
)
Back
|
FazBrowse Home
|
New Git URL