Opened 12 years ago

Closed 12 years ago

#20548 closed Bug (fixed)

Deprecation warnings when running the test suite

Reported by: Aymeric Augustin Owned by: nobody
Component: Testing framework Version: dev
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When running the test suite with:

cd tests; PYTHONPATH=.. python3.3 -Wd runtests.py --settings=test_sqlite

the following warnings are displayed at compile time:

django/contrib/comments/__init__.py:9: PendingDeprecationWarning: django.contrib.comments is deprecated and will be removed before Django 1.8.
  warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", PendingDeprecationWarning)
tests/model_forms_regress/tests.py:96: PendingDeprecationWarning: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is deprecated - form PartiallyLocalizedTripleForm needs updating
  class PartiallyLocalizedTripleForm(forms.ModelForm):
tests/model_forms_regress/tests.py:102: PendingDeprecationWarning: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is deprecated - form FullyLocalizedTripleForm needs updating
  class FullyLocalizedTripleForm(forms.ModelForm):
django/test/_doctest.py:57: PendingDeprecationWarning: The django.test._doctest module is deprecated; use the doctest module from the Python standard library instead.
  PendingDeprecationWarning)
django/test/simple.py:24: PendingDeprecationWarning: The django.test.simple module and DjangoTestSuiteRunner are deprecated; use django.test.runner.DiscoverRunner instead.
  PendingDeprecationWarning)

and the following warnings are displayed at runtime:

/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/case.py:135: PendingDeprecationWarning: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is deprecated - form Form needs updating
  callable_obj(*args, **kwargs)
tests/forms_tests/tests/tests.py:223: PendingDeprecationWarning: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is deprecated - form Form needs updating
  self.assertTrue(issubclass(ModelFormMetaclass(str('Form'), (ModelForm,), {'Meta': Meta}), ModelForm))
django/db/models/base.py:418: ResourceWarning: unclosed <socket.socket object, fd=9, family=2, type=1, proto=0>
  super(Model, self).__init__()

There's also fourteen ResourceWarning: unclosed file ... warnings from the form wizard tests which I haven't copied.


The one in django.contrib.comments is tracked in #20065.

The fourteen in django.contrib.formtools are tracked in #19905.

I don't know where the one in django.db comes from. That's hard to guess without turning it into an exception.

The two in django.test were discussed in #20503; I'm still seeing them with latest master.

All the others are most likely a consequence of #19733.


Since I'd like the test suite to run without deprecation warnings in the 1.6 release, I'm filing this ticket to drive some attention to this issue.

Change History (5)

comment:1 by Kamu, 12 years ago

Component: UncategorizedTesting framework
Triage Stage: UnreviewedAccepted

comment:2 by Marc Tamlyn, 12 years ago

What is the correct resolution to tests on deprecated functionality? The django.test warnings come from three tests which import django.test.simple (which in turn imports django.test._doctest). The modules affected are:

  • tests.test_runner - 4 tests using get_tests and DjangoTestSuiteRunner
  • tests.test_suite_override - whole module tests build_suite
  • tests.test_utils - One test for make_doctest

The options as I see it are:

  • Remove the offending tests, and therefore their imports
  • Move the relevant imports into the tests and use warnings to suppress the import warnings

comment:3 by Luke Plant, 12 years ago

We don't remove the tests until the functionality they test is gone, so it's option 2.

comment:4 by Preston Timmons, 12 years ago

Luke's right, the test runner tests need to stay until the old test runner is removed.

I might be missing something, but after #20503 was committed I'm not able to reproduce the deprecation errors in the tests under Python 3.3.

comment:5 by Aymeric Augustin, 12 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top