#26122: Weird test regression in 1.8.5
-----------------------------------+--------------------
Reporter: knyghty | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------
Smallest example I could get to:
{{{
# forms.py
from django import forms
from django.contrib.auth import get_user_model
class InlineEditEmailForm(forms.ModelForm):
class Meta:
model = get_user_model()
fields = ['email']
# views.py
import copy
from django.http import HttpResponse
from .forms import InlineEditEmailForm
def edit_user_email(request):
user = request.user
old_user_data = copy.copy(user)
form = InlineEditEmailForm(data=request.POST, instance=user)
if form.is_valid():
new_user_data = form.cleaned_data
user = form.save()
if old_user_data.email != new_user_data['email']:
response = HttpResponse()
response.status_code = 200
return response
response = HttpResponse()
response.status_code = 400
return response
# tests.py
from django.contrib.auth import get_user_model
from django.test import TestCase
class EditUserEmailTestCase(TestCase):
def test_post(self):
get_user_model().objects.create_user('test', '[email protected]',
'pw')
data = {'email': '[email protected]'}
self.client.login(username='test', password='pw')
response = self.client.post('/', data)
self.assertEqual(response.status_code, 200)
}}}
* Works in 1.8.4, doesn't work in 1.8.5+ or 1.9.
* Works when using a browser, only fails during tests.
* Changing first line of the view to {{{user =
get_user_model().objects.create_user(...)}}} makes the test pass again.
--
Ticket URL: <https://code.djangoproject.com/ticket/26122>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.d9fc21821cced750c93c8004eb47930b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.