Code

#20059 closed Bug (fixed)

Test failure in humanize app for some languages

Reported by: orangain@… Owned by: matiasb
Component: contrib.humanize Version: 1.5
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

Hi,

The tests of humanize app failed for LANGUAGE_CODE = 'ja-jp'.

The problem was also reproduced for other LANGUAGE_CODEs such as 'fr-fr', 'de-de'.

When the LANGUAGE_CODE was default value, 'en-us', the tests succeeded.

How to reproduce

  1. Create a new project.
    $ pip install django==1.5
    $ django-admin.py startproject sample
    
  1. Edit the sample/sample/settings.py like below:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3', # Use sqlite3
            'NAME': ':memory:',
           ……
        }
    }
    
    #LANGUAGE_CODE = 'en-us'
    LANGUAGE_CODE = 'ja-jp' # Change to Japanese
    
    INSTALLED_APPS = (
        ……
        'django.contrib.humanize', # Add humanize app
    )
    
  1. Run the tests and see the failure.
    $ python sample/manage.py test humanize
    Creating test database for alias 'default'…
    F..F.FF..FFF
    ======================================================================
    FAIL: test_apnumber (django.contrib.humanize.tests.HumanizeTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 121, in test_apnumber
        self.humanize_tester(test_list, result_list, 'apnumber')
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 47, in humanize_tester
        msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result))
    AssertionError: apnumber test failed, produced '1', should've produced 'one'
    
    ======================================================================
    FAIL: test_intcomma (django.contrib.humanize.tests.HumanizeTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 67, in test_intcomma
        self.humanize_tester(test_list, result_list, 'intcomma')
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 47, in humanize_tester
        msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result))
    AssertionError: intcomma test failed, produced '1000', should've produced '1,000'
    
    ======================================================================
    FAIL: test_intword (django.contrib.humanize.tests.HumanizeTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 95, in test_intword
        self.humanize_tester(test_list, result_list, 'intword')
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 47, in humanize_tester
        msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result))
    AssertionError: intword test failed, produced '1.0\u767e\u4e07', should've produced '1.0 million'
    
    ======================================================================
    FAIL: test_l10n_intcomma (django.contrib.humanize.tests.HumanizeTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 78, in test_l10n_intcomma
        self.humanize_tester(test_list, result_list, 'intcomma')
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 47, in humanize_tester
        msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result))
    AssertionError: intcomma test failed, produced '1000', should've produced '1,000'
    
    ======================================================================
    FAIL: test_naturalday_uses_localtime (django.contrib.humanize.tests.HumanizeTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 161, in test_naturalday_uses_localtime
        self.humanize_tester([dt], ['yesterday'], 'natural day'
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 47, in humanize_tester
        msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result))
    AssertionError: naturalday test failed, produced '\u6628\u65e5', should've produced 'yesterday'
    
    ======================================================================
    FAIL: test_naturaltime (django.contrib.humanize.tests.HumanizeTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 222, in test_naturaltime
        self.humanize_tester(test_list, result_list, 'natural time'
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 47, in humanize_tester
        msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result))
    AssertionError: naturaltime test failed, produced '\u4eca', should've produced 'now'
    
    ======================================================================
    FAIL: test_ordinal (django.contrib.humanize.tests.HumanizeTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 57, in test_ordinal
        self.humanize_tester(test_list, result_list, 'ordinal')
      File "/Users/****/humanize-bug-reproduction-1.5/venv/lib/python2.7/site-packages/django/contrib/humanize/tests.py", line 47, in humanize_tester
        msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result))
    AssertionError: ordinal test failed, produced '1\u756a\u76ee', should've produced '1st'
    
    ----------------------------------------------------------------------
    Ran 12 tests in 0.060s
    
    FAILED (failures=7)
    Destroying test database for alias 'default'…))
    

Other information

  • Python 2.7, Mac OSX.
  • The problem was also reproduced on master (0122a98dad6a7785def47466814ed2ae8d244143).
  • The problem was also reproduced on Django 1.4.2, but it seems somewhat strange. On 1.4.2, python manage.py test humanize failed too, but python manage.py test succeeded.

Attachments (0)

Change History (4)

comment:1 Changed 16 months ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 16 months ago by matiasb

  • Owner changed from nobody to matiasb
  • Status changed from new to assigned

comment:3 Changed 16 months ago by matiasb

  • Has patch set

Created pull request: https://github.com/django/django/pull/945
All tests passing with SQLite.

comment:4 Changed 16 months ago by Florian Apolloner <florian@…>

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

In 86aaff75d09fb9c801ec29d1f961cd4706043be9:

Fixed #20059 -- Updated humanize tests to force 'en' language setting.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.