def test_before_dt_format(): with pytest.raises(ValidationError) as e: before(datetime(2015, 1, 1, 0, 0, 0), dt_format='%Y-%m-%d')(datetime(2015, 1, 2, 0, 0, 0)) assert e.value.message == 'Value is after 2015-01-01.'
def test_before_greater_than(): with pytest.raises(ValidationError): before(datetime(2015, 1, 1, 0, 0, 0))(datetime(2015, 1, 1, 0, 0, 1))
def test_before_equal(): before(datetime(2015, 1, 1, 0, 0, 0))(datetime(2015, 1, 1, 0, 0, 0))
def test_before_less_than(): before(datetime(2015, 1, 1, 0, 0, 0))(datetime(2014, 12, 31, 23, 59, 59))
def test_before_datetime_date(): before(datetime(2015, 1, 1, 0, 0, 0))(date(2014, 12, 31))
def test_before_date_datetime(): before(date(2015, 1, 1))(datetime(2014, 12, 31, 23, 59, 59))