Opened 11 months ago

Closed 11 months ago

Last modified 11 months ago

#22335 closed Bug (fixed)

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

Reported by: zsiciarz Owned by: zsiciarz
Component: Core (Management commands) Version: master
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 Changed 11 months ago by zsiciarz

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to zsiciarz
  • Patch needs improvement unset
  • Status changed from new to assigned

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

comment:2 Changed 11 months ago by Zbigniew Siciarz <antyqjon@…>

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

In 3cdb0baa453e2cc09c0a5c5c04cce66a6dc4e789:

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

comment:3 Changed 11 months ago by Claude Paroz <claude@…>

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