Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23651 closed Bug (fixed)

fixtures.tests.FixtureLoadingTests.test_loading_and_dumping fails with Python 3

Reported by: Raphaël Hertzog Owned by: nobody
Component: Core (Management commands) Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When running the test suite with Python 3.4.2 you get this error:

======================================================================
FAIL: test_loading_and_dumping (fixtures.tests.FixtureLoadingTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/«PKGBUILDDIR»/tests/fixtures/tests.py", line 170, in test_loading_and_dumping
    self.assertEqual(len(w), 0)
AssertionError: 1 != 0

The failing code is this:

        # An attempt to load a nonexistent 'initial_data' fixture isn't an error
        with warnings.catch_warnings(record=True) as w:
            management.call_command('loaddata', 'initial_data.json', verbosity=0)
        self.assertEqual(len(w), 0)

It seems that the code is generating a RemovedInDjango19Warning warning about deprecation of initial_data fixtures:

From django/core/management/commands/loaddata.py line 297:

        elif fixture_name == 'initial_data' and fixture_files:
            warnings.warn(
                'initial_data fixtures are deprecated. Use data migrations instead.',
                RemovedInDjango19Warning
            )

It's not clear why this test only started failing recently, it might related to a change between Python 3.4.1 and 3.4.2 but I could not identify which one.

This bug has been initially reported in Debian: http://bugs.debian.org/765117 and Brian May did the initial investigation that I report here. Thank you for your help.

Change History (6)

comment:1 by Claude Paroz, 10 years ago

It's not clear why this test only started failing recently, it might related to a change between Python 3.4.1 and 3.4.2 but I could not identify which one.

Maybe that one: http://bugs.python.org/issue4180 ?

comment:2 by Raphaël Hertzog, 10 years ago

In any case, the true problem is that initial_data.json does actually exist: it's in tests/fixtures/fixtures/initial_data.json and the test code assumes that it doesn't exist while the loaddata management command does actually find it (otherwise the "and fixture_files" would avoid the warning entirely).

With Python 2 we get to the same point, i.e. we call warnings.warn(..., RemovedInDjango19Warning) but it never bubbles up to the catch_warnings(). Maybe the bug that got fixed in Python 3 is not yet fixed in Python 2...

comment:3 by Claude Paroz, 10 years ago

Has patch: set
Severity: Release blockerNormal
Triage Stage: UnreviewedAccepted

Raphaël, with the following pull request, does Python 3.4.2 still fail?
https://github.com/django/django/pull/3366

in reply to:  3 comment:4 by Raphaël Hertzog, 10 years ago

Replying to claudep:

Raphaël, with the following pull request, does Python 3.4.2 still fail?
https://github.com/django/django/pull/3366

No, the tests are succeeding now.

comment:5 by Claude Paroz <claude@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 7a893ee77171d6cc37ffd40d67af6161633235e0:

Fixed #23651 -- Isolated non-existent fixture tests

Previous versions of the tests were buggy, as initial_data.json
did exist and the test wasn't failing. It was finally failing on
Python 3.4.2.
Thanks Raphaël Hertzog for the report (and Debian bug #765117
contributors).

comment:6 by Claude Paroz <claude@…>, 10 years ago

In da0ebe39f6ed1edc4043c97f6fd7e6872ba86508:

[1.7.x] Fixed #23651 -- Isolated non-existent fixture tests

Previous versions of the tests were buggy, as initial_data.json
did exist and the test wasn't failing. It was finally failing on
Python 3.4.2.
Thanks Raphaël Hertzog for the report (and Debian bug #765117
contributors).
Backport of 7a893ee771 from master.

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