<s> import os <EOL> import inspect <EOL> import sys <EOL> from os . path import abspath , dirname , exists , join <EOL> import pytest <EOL> from . . util import yesno <EOL> from . . test_support import pytest_plugin <EOL> class _TryAgain ( Exception ) : <EOL> pass <EOL> class PyFrcTest : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , parser = None ) : <EOL> if parser : <EOL> parser . add_argument ( '<STR_LIT>' , default = False , action = '<STR_LIT:store_true>' , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT>' , default = False , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , nargs = '<STR_LIT:*>' , <EOL> help = "<STR_LIT>" ) <EOL> def run ( self , options , robot_class , ** static_options ) : <EOL> from . . import config <EOL> config . mode = '<STR_LIT:test>' <EOL> config . coverage_mode = options . coverage_mode <EOL> return self . run_test ( options . pytest_args , robot_class , options . builtin , ** static_options ) <EOL> def run_test ( self , * a , ** k ) : <EOL> try : <EOL> return self . _run_test ( * a , ** k ) <EOL> except _TryAgain : <EOL> return self . _run_test ( * a , ** k ) <EOL> def _run_test ( self , pytest_args , robot_class , use_builtin , ** static_options ) : <EOL> curdir = abspath ( os . getcwd ( ) ) <EOL> self . robot_class = robot_class <EOL> robot_file = abspath ( inspect . getfile ( robot_class ) ) <EOL> robot_path = dirname ( robot_file ) <EOL> if robot_file . endswith ( '<STR_LIT>' ) : <EOL> robot_file = join ( curdir , '<STR_LIT>' ) <EOL> robot_path = curdir <EOL> if not exists ( robot_file ) : <EOL> print ( "<STR_LIT>" ) <EOL> return <NUM_LIT:1> <EOL> self . try_dirs = [ <EOL> abspath ( join ( robot_path , '<STR_LIT>' ) ) , <EOL> abspath ( join ( robot_path , '<STR_LIT:..>' , '<STR_LIT>' ) ) <EOL> ] <EOL> for d in self . try_dirs : <EOL> if exists ( d ) : <EOL> test_directory = d <EOL> os . chdir ( test_directory ) <EOL> break <EOL> else : <EOL> if not use_builtin : <EOL> print ( "<STR_LIT>" ) <EOL> retv = self . _no_tests ( ) <EOL> return <NUM_LIT:1> <EOL> from . . tests import basic <EOL> pytest_args . insert ( <NUM_LIT:0> , abspath ( inspect . getfile ( basic ) ) ) <EOL> try : <EOL> retv = pytest . main ( pytest_args , <EOL> plugins = [ pytest_plugin . PyFrcPlugin ( robot_class , <EOL> robot_file , <EOL> robot_path ) ] ) <EOL> finally : <EOL> os . chdir ( curdir ) <EOL> if retv == <NUM_LIT:5> : <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> retv = self . _no_tests ( retv ) <EOL> return retv <EOL> def _no_tests ( self , r = <NUM_LIT:1> ) : <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> for d in self . try_dirs : <EOL> print ( '<STR_LIT>' % d ) <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( ) <EOL> if not sys . stdin . isatty ( ) : <EOL> print ( "<STR_LIT>" ) <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( ) <EOL> else : <EOL> if yesno ( "<STR_LIT>" ) : <EOL> from . cli_add_tests import PyFrcAddTests <EOL> add_tests = PyFrcAddTests ( ) <EOL> add_tests . run ( None , self . robot_class ) <EOL> raise _TryAgain ( ) <EOL> return r </s>
