<s> from django . core . exceptions import ImproperlyConfigured <EOL> from django . core . management import call_command , CommandError <EOL> from django . core . management . base import BaseCommand <EOL> from django . conf import settings <EOL> from django . db . models import loading <EOL> from django . test import simple <EOL> from south . migration import Migrations <EOL> from south . exceptions import NoMigrations <EOL> from south . hacks import hacks <EOL> class Command ( BaseCommand ) : <EOL> help = "<STR_LIT>" <EOL> usage_str = "<STR_LIT>" <EOL> def handle ( self , check_app_name = None , ** options ) : <EOL> runner = simple . DjangoTestSuiteRunner ( verbosity = <NUM_LIT:0> ) <EOL> err_msg = "<STR_LIT>" <EOL> hacks . patch_flush_during_test_db_creation ( ) <EOL> failures = <NUM_LIT:0> <EOL> if check_app_name is None : <EOL> app_names = settings . INSTALLED_APPS <EOL> else : <EOL> app_names = [ check_app_name ] <EOL> for app_name in app_names : <EOL> app_label = app_name . split ( "<STR_LIT:.>" ) [ - <NUM_LIT:1> ] <EOL> if app_name == '<STR_LIT>' : <EOL> continue <EOL> try : <EOL> Migrations ( app_name ) <EOL> except ( NoMigrations , ImproperlyConfigured ) : <EOL> continue <EOL> app = loading . get_app ( app_label ) <EOL> verbosity = int ( options . get ( '<STR_LIT>' , <NUM_LIT:1> ) ) <EOL> if verbosity >= <NUM_LIT:1> : <EOL> self . stderr . write ( "<STR_LIT>" % app_name ) <EOL> old_config = runner . setup_databases ( ) <EOL> try : <EOL> call_command ( '<STR_LIT>' , app_label , noinput = True , verbosity = verbosity ) <EOL> for model in loading . get_models ( app ) : <EOL> dummy = model . _default_manager . exists ( ) <EOL> except ( KeyboardInterrupt , SystemExit ) : <EOL> raise <EOL> except Exception as e : <EOL> failures += <NUM_LIT:1> <EOL> if verbosity >= <NUM_LIT:1> : <EOL> self . stderr . write ( err_msg % app_name ) <EOL> self . stderr . write ( "<STR_LIT>" % e ) <EOL> finally : <EOL> runner . teardown_databases ( old_config ) <EOL> if failures > <NUM_LIT:0> : <EOL> raise CommandError ( "<STR_LIT>" % failures ) <EOL> self . stderr . write ( "<STR_LIT>" ) </s>
