<s> import os <EOL> import sys <EOL> from django . core import management <EOL> from django . core . management import CommandError <EOL> from django . core . management . utils import find_command , popen_wrapper <EOL> from django . test import SimpleTestCase <EOL> from django . utils import translation <EOL> from django . utils . six import StringIO <EOL> class CommandTests ( SimpleTestCase ) : <EOL> def test_command ( self ) : <EOL> out = StringIO ( ) <EOL> management . call_command ( '<STR_LIT>' , stdout = out ) <EOL> self . assertEqual ( out . getvalue ( ) , <EOL> "<STR_LIT>" ) <EOL> def test_command_style ( self ) : <EOL> out = StringIO ( ) <EOL> management . call_command ( '<STR_LIT>' , style = '<STR_LIT>' , stdout = out ) <EOL> self . assertEqual ( out . getvalue ( ) , <EOL> "<STR_LIT>" ) <EOL> def test_language_preserved ( self ) : <EOL> out = StringIO ( ) <EOL> with translation . override ( '<STR_LIT>' ) : <EOL> management . call_command ( '<STR_LIT>' , stdout = out ) <EOL> self . assertEqual ( translation . get_language ( ) , '<STR_LIT>' ) <EOL> def test_explode ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertRaises ( CommandError , management . call_command , ( '<STR_LIT>' , ) ) <EOL> def test_system_exit ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( CommandError ) : <EOL> management . call_command ( '<STR_LIT>' , example = "<STR_LIT>" ) <EOL> old_stderr = sys . stderr <EOL> sys . stderr = err = StringIO ( ) <EOL> try : <EOL> with self . assertRaises ( SystemExit ) : <EOL> management . ManagementUtility ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) . execute ( ) <EOL> finally : <EOL> sys . stderr = old_stderr <EOL> self . assertIn ( "<STR_LIT>" , err . getvalue ( ) ) <EOL> def test_default_en_us_locale_set ( self ) : <EOL> out = StringIO ( ) <EOL> with translation . override ( '<STR_LIT>' ) : <EOL> management . call_command ( '<STR_LIT>' , stdout = out ) <EOL> self . assertEqual ( out . getvalue ( ) , "<STR_LIT>" ) <EOL> def test_configured_locale_preserved ( self ) : <EOL> out = StringIO ( ) <EOL> with translation . override ( '<STR_LIT>' ) : <EOL> management . call_command ( '<STR_LIT>' , stdout = out ) <EOL> self . assertEqual ( out . getvalue ( ) , "<STR_LIT>" ) <EOL> def test_find_command_without_PATH ( self ) : <EOL> """<STR_LIT>""" <EOL> current_path = os . environ . pop ( '<STR_LIT>' , None ) <EOL> try : <EOL> self . assertIsNone ( find_command ( '<STR_LIT>' ) ) <EOL> finally : <EOL> if current_path is not None : <EOL> os . environ [ '<STR_LIT>' ] = current_path <EOL> class UtilsTests ( SimpleTestCase ) : <EOL> def test_no_existent_external_program ( self ) : <EOL> self . assertRaises ( CommandError , popen_wrapper , [ '<STR_LIT>' ] ) </s>
