#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 , 11 years ago
comment:2 by , 11 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...
follow-up: 4 comment:3 by , 11 years ago
| Has patch: | set |
|---|---|
| Severity: | Release blocker → Normal |
| Triage Stage: | Unreviewed → Accepted |
Raphaël, with the following pull request, does Python 3.4.2 still fail?
https://github.com/django/django/pull/3366
comment:4 by , 11 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 , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Maybe that one: http://bugs.python.org/issue4180 ?