Skip to content

Commit

Permalink
Change RequiredInterval creation to fail if arguments are NaN.
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnbrown committed Jul 22, 2019
1 parent e8435b1 commit c962e04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions datatest/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,8 @@ def __init__(self, min=None, max=None, show_expected=False):
right_bounded = max is not None

if left_bounded and right_bounded:
if max < min:
raise ValueError("'max' must not be less than 'min'")
if not min <= max:
raise ValueError("'min' must not be greater than 'max'")

def interval(element):
try:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,9 @@ def test_right_bound(self):
self.assertEqual(desc, 'exceeds maximum expected value of 4')

def test_bad_args(self):
with self.assertRaises(ValueError, msg='must not accept NaN'):
requirement = RequiredInterval(5, float('nan'))

with self.assertRaises(ValueError, msg='lower must not be greater than upper'):
requirement = RequiredInterval(6, 5)

Expand Down

0 comments on commit c962e04

Please sign in to comment.