Opened 5 years ago

Last modified 5 years ago

#26122 closed Bug

Weird test regression in 1.8.5 — at Initial Version

Reported by: Tom Carrick Owned by: nobody
Component: Utilities Version: 1.8
Severity: Release blocker Keywords:
Cc: Ben Kraft Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Smallest example I could get to:

from django import forms
from django.contrib.auth import get_user_model

class InlineEditEmailForm(forms.ModelForm):
    class Meta:
        model = get_user_model()
        fields = ['email']

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 =

        if != new_user_data['email']:
            response = HttpResponse()
            response.status_code = 200
            return response

    response = HttpResponse()
    response.status_code = 400
    return response

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', '', 'pw')
        data = {'email': ''}
        self.client.login(username='test', password='pw')
        response ='/', 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.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top