Contractions in Django 3.0 and Django 2.2

21 views
Skip to first unread message

One Above All

unread,
Feb 8, 2020, 8:48:57 AM2/8/20
to Django users
i am working on a project which is adding support for Django 3.0. While doing so, I came across ticket # 30400 https://code.djangoproject.com/ticket/30400 after which contractions were rewritten. I am writing a test which should work with both Django 3.0 and 2.2. I have to assert error_messages in django.contrib.auth.forms.SetPasswordForm like below

self.assertIn("The two password fields didn’t match.", str(response.data['new_password2']))

How can I make this work in both versions of Django ?

Thanks and Regards,
Gagan Deep 

אורי

unread,
Feb 8, 2020, 10:09:22 AM2/8/20
to django...@googlegroups.com
You can check which Django version is used and assert accordingly.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/18f30e79-1c67-46b6-9482-d6f18a109887%40googlegroups.com.

אורי

unread,
Feb 8, 2020, 10:11:44 AM2/8/20
to django...@googlegroups.com
For example in this case:

if (django.VERSION >= (3, 0)):
    ...
else:
    ...


On Sat, Feb 8, 2020 at 3:48 PM One Above All <the.one.abo...@gmail.com> wrote:
--

One Above All

unread,
Feb 9, 2020, 3:09:39 AM2/9/20
to django...@googlegroups.com
I just replaced single quotes with that special character from response string using replace method of string,

Reply all
Reply to author
Forward
0 new messages