<s> import argparse <EOL> import sys <EOL> import os <EOL> import subprocess <EOL> import pytest <EOL> sys . path . append ( os . path . dirname ( __file__ ) ) <EOL> def exit_on_failure ( ret , message = None ) : <EOL> if ret : <EOL> sys . exit ( ret ) <EOL> def run_django_tests ( args ) : <EOL> """<STR_LIT>""" <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> try : <EOL> from django . test . utils import get_runner <EOL> from tests . conftest import pytest_configure <EOL> settings = pytest_configure ( ) <EOL> TestRunner = get_runner ( settings ) <EOL> test_runner = TestRunner ( ) <EOL> exit_on_failure ( test_runner . run_tests ( args ) ) <EOL> except ImproperlyConfigured : <EOL> sys . exit ( '<STR_LIT>' ) <EOL> def flake8_main ( args ) : <EOL> print ( '<STR_LIT>' ) <EOL> ret = subprocess . call ( [ '<STR_LIT>' ] + args ) <EOL> print ( '<STR_LIT>' if ret else '<STR_LIT>' ) <EOL> return ret <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> parser = argparse . ArgumentParser ( ) <EOL> parser . add_argument ( '<STR_LIT>' , metavar = "<STR_LIT:args>" , type = str , nargs = '<STR_LIT:*>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' ) <EOL> parser . add_argument ( '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' ) <EOL> parser . add_argument ( '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' ) <EOL> args = parser . parse_args ( ) <EOL> extra_args = args . extra_args <EOL> if not args . flake8_only : <EOL> if args . django : <EOL> run_django_tests ( extra_args ) <EOL> extra_args = [ ] <EOL> else : <EOL> exit_on_failure ( pytest . main ( extra_args ) ) <EOL> if not args . no_flake8 : <EOL> exit_on_failure ( flake8_main ( extra_args ) ) </s>
