Opened 5 years ago

Closed 5 years ago

#17054 closed Bug (fixed)

Django test suite does not run if gettext not installed

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


This commit:

Converts the import of commands.tests in regression_tests/i18n from a * import to an explicit list.

The problem is that those tests are conditionally imported in commands.tests based on whether the user has certain commands installed on their command line (xgettext and msgfmt to be exact). If those commands are not installed, the tests aren't loaded and the import in the main i18n.tests file fails. The result is that it's not possible to run the test suite:

$ ./ --settings=test_sqlite i18n
Traceback (most recent call last):
  File "./", line 286, in <module>
    failures = django_tests(int(options.verbosity), options.interactive, options.failfast, args)
  File "./", line 153, in django_tests
    failures = test_runner.run_tests(test_labels, extra_tests=extra_tests)
  File "/Users/jsdalton/webs/testproject/src/django/django/test/", line 353, in run_tests
    suite = self.build_suite(test_labels, extra_tests)
  File "/Users/jsdalton/webs/testproject/src/django/django/test/", line 243, in build_suite
  File "/Users/jsdalton/webs/testproject/src/django/django/test/", line 72, in build_suite
    test_module = get_tests(app_module)
  File "/Users/jsdalton/webs/testproject/src/django/django/test/", line 33, in get_tests
    test_module = import_module('.'.join(prefix + [TEST_MODULE]))
  File "/Users/jsdalton/webs/testproject/src/django/django/utils/", line 35, in import_module
  File "/Users/jsdalton/webs/testproject/src/django/tests/regressiontests/i18n/", line 25, in <module>
    from .commands.tests import NoWrapExtractorTests, IgnoredExtractorTests, MessageCompilationTests, PoFileTests, BasicExtractorTests, JavascriptExtractorTests, CopyPluralFormsExtractorTests, SymlinkExtractorTests, ExtractorTests
ImportError: cannot import name NoWrapExtractorTests

Easy fix is convert this line back to a * import. Better fix is....??? I'll think about it.

Attachments (1)

17054.patch (2.5 KB) - added by aaugustin 5 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 5 years ago by jsdalton

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 5 years ago by aaugustin

  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

Changed 5 years ago by aaugustin

comment:3 Changed 5 years ago by aaugustin

Idea for a better fixed attached -- not tested.

comment:4 Changed 5 years ago by jsdalton

Thanks Aymeric. This patch does the trick for me and looks like a solid solution to the problem.

comment:5 Changed 5 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from new to closed

In [17013]:

Fixed #17054 -- Ensured the test suite runs when gettext isn't available, after r16981.

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