Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#27951 closed Bug (fixed)

Nondeterministic ordering test failure in model_forms on Oracle

Reported by: Shai Berger Owned by: nobody
Component: Forms Version: 1.11
Severity: Release blocker Keywords: test
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This from our CI:

======================================================================
FAIL [0.018s]: test_to_field_name_with_initial_data (model_forms.tests.ModelMultipleChoiceFieldTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "<https://djangoci.com/job/django-oracle-1.11/database=oracle12,label=trusty,python=python2.7/ws/tests/model_forms/tests.py",> line 1974, in test_to_field_name_with_initial_data
    self.assertEqual(form['categories'].value(), [self.c2.slug, self.c3.slug])
AssertionError: Lists differ: [u'third-test', u'its-test'] != [u'its-test', u'third-test']

First differing element 0:
u'third-test'
u'its-test'

- [u'third-test', u'its-test']
+ [u'its-test', u'third-test']

----------------------------------------------------------------------

The relevant code in stable/1.11.x is:

    def test_to_field_name_with_initial_data(self):
        class ArticleCategoriesForm(forms.ModelForm):
            categories = forms.ModelMultipleChoiceField(Category.objects.all(), to_field_name='slug')

            class Meta:
                model = Article
                fields = ['categories']

        article = Article.objects.create(
            headline='Test article',
            slug='test-article',
            pub_date=datetime.date(1988, 1, 4),
            writer=Writer.objects.create(name='Test writer'),
            article='Hello.',
        )
        article.categories.add(self.c2, self.c3)
        form = ArticleCategoriesForm(instance=article)
        self.assertEqual(form['categories'].value(), [self.c2.slug, self.c3.slug])

In master it's the same except that the assertEqual in the end is replaced with assertCountEqual which ignore the order of items. I propose that we backport this change (ticket opened really mostly because we're in code freeze).

Change History (2)

comment:2 by Shai Berger, 8 years ago

Resolution: fixed
Status: newclosed

I seem to have lost all my Trac-fu...

Version 0, edited 8 years ago by Shai Berger (next)

comment:3 by Tim Graham, 8 years ago

Component: UncategorizedForms
Summary: Failure in Oracle testNondeterministic ordering test failure in model_forms on Oracle
Note: See TracTickets for help on using tickets.
Back to Top