28👍
✅
assertRaises
is used as a context manager:
def test_validate_percent(self):
with self.assertRaises(ValidationError):
validate_percent(1000)
or with a callable:
def test_validate_percent(self):
self.assertRaises(ValidationError, validate_percent, 1000)
3👍
def test_validate_percent(self):
self.assertRaises(ValidationError, validate_percent, 1000)
- How do you update a Django Form Meta class fields dynamically from the form constructor?
- Geodjango using mysql
- Pagination and get parameters
- In Django how do I notify a parent when a child is saved in a foreign key relationship?
Source:stackexchange.com