Opened 7 years ago

Closed 7 years ago

Last modified 7 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, 7 years ago

Resolution: fixed
Status: newclosed

In 17d75472f0d74792ae3195b01e23233cc84d4d96:

[1.11.x] Fixed nondeterministic ordering test failure in model_forms.

Backport of 2767ef3ca7fcd5608327a246c74b1dfb11ea0413 from master

In e7c61ff3a6d11e956da167d2456fc61bd0491b67

[1.10.x] Fixed nondeterministic ordering test failure in model_forms.

Backport of 2767ef3ca7fcd5608327a246c74b1dfb11ea0413 from master

Last edited 7 years ago by Tim Graham (previous) (diff)

comment:3 by Tim Graham, 7 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