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.
The following pull request fixes the issue: https://github.com/django/django/pull/2481