Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#22335 closed Bug (fixed)

tests.user_commands.UtilsTests failure on non-English Windows systems

Reported by: Zbigniew Siciarz Owned by: Zbigniew Siciarz
Component: Core (Management commands) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

While working my way towards #22234, I've noticed that current master doesn't pass the test suite on Windows if the system language is other than English. This is the output from running that test on Windows 7 (Polish language, Python 2.7.2):

(django-dev) C:\Users\USER\v\django-dev\django\tests>python runtests.py user_commands.tests.UtilsTests
Testing against Django installed in 'c:\users\user\v\django-dev\django\django'
Creating test database for alias 'default'...
Creating test database for alias 'other'...
E
======================================================================
ERROR: test_no_existent_external_program (user_commands.tests.UtilsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\USER\v\django-dev\django\tests\user_commands\tests.py", line 81, in test_no_existent_external
_program
    self.assertRaises(CommandError, popen_wrapper, ['a_42_command_that_doesnt_exist_42'])
  File "D:\Python27\Lib\unittest\case.py", line 471, in assertRaises
    callableObj(*args, **kwargs)
  File "c:\users\user\v\django-dev\django\django\core\management\utils.py", line 24, in popen_wrapper
    (args[0], e.strerror)), sys.exc_info()[2])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xbf in position 6: ordinal not in range(128)

----------------------------------------------------------------------
Ran 1 test in 0.045s

FAILED (errors=1)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...

This failure appears to be caused by a localized system error. The test expects that a CommandError is raised, saying that a program cannot be found. The actual error message is extracted from the original operating system error. On English Windows, the message says The system cannot find the file specified and the test passes. In case of Polish language, the error says Nie można odnaleźć określonego pliku (oops, non-ASCII characters here) and the test fails as seen above. Wrapping the system error with force_text should solve this problem.

Change History (3)

comment:1 by Zbigniew Siciarz, 11 years ago

Has patch: set
Owner: changed from nobody to Zbigniew Siciarz
Status: newassigned

The following pull request fixes the issue: https://github.com/django/django/pull/2481

comment:2 by Zbigniew Siciarz <antyqjon@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 3cdb0baa453e2cc09c0a5c5c04cce66a6dc4e789:

Fixed #22335 -- Fixed popen_wrapper error on non-English Windows systems.

comment:3 by Claude Paroz <claude@…>, 11 years ago

In ab4c96cff08b7a196807c0faaeca1b8b7ad1e8ea:

Merge pull request #2481 from zsiciarz/ticket-22335

Fixed #22335 -- Fixed popen_wrapper error on non-English Windows systems.

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