forked from python-validators/validators
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_between.py
More file actions
33 lines (26 loc) · 863 Bytes
/
Copy pathtest_between.py
File metadata and controls
33 lines (26 loc) · 863 Bytes
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
# -*- coding: utf-8 -*-
import pytest
import validators
@pytest.mark.parametrize(('value', 'min', 'max'), [
(12, 11, 13),
(12, None, 14),
(12, 11, None),
(12, 12, 12)
])
def test_returns_true_on_valid_range(value, min, max):
assert validators.between(value, min=min, max=max)
@pytest.mark.parametrize(('value', 'min', 'max'), [
(12, 13, 12),
(12, None, None),
])
def test_raises_assertion_error_for_invalid_args(value, min, max):
with pytest.raises(AssertionError):
assert validators.between(value, min=min, max=max)
@pytest.mark.parametrize(('value', 'min', 'max'), [
(12, 13, 14),
(12, None, 11),
(12, 13, None)
])
def test_returns_failed_validation_on_invalid_range(value, min, max):
result = validators.between(value, min=min, max=max)
assert isinstance(result, validators.ValidationFailure)