25👍
You are looking for assertRegex()
:
class SomeTestCases(TestCase):
def test_something(self):
response = self.client.post(...)
self.assertRegex(response.data, r'^your regex here$')
See also assertNotRegex
.
👤mrts
8👍
Seems like regex would be the easiest solution here
import re
msg = 'Geometry type "point" is not supported'
assert re.match(r'^Geometry type ".+" is not supported$', msg)
- Get all related many-to-many objects from a Django QuerySet
- How can i get all models in django 1.8
- Best way to make Django's "user" system have "friends"
Source:stackexchange.com