<s> """<STR_LIT>""" <EOL> import os <EOL> from itertools import product <EOL> import pytest <EOL> from pyop2 import op2 <EOL> from pyop2 . backends import backends <EOL> def pytest_cmdline_preparse ( config , args ) : <EOL> if '<STR_LIT>' in os . environ and '<STR_LIT>' not in args : <EOL> args . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> if '<STR_LIT>' in os . environ and '<STR_LIT>' not in args : <EOL> args . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> if '<STR_LIT>' in os . environ and '<STR_LIT>' not in args : <EOL> args . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> if '<STR_LIT>' in os . environ and not any ( '<STR_LIT>' in a for a in args ) : <EOL> args . insert ( <NUM_LIT:0> , '<STR_LIT>' + os . environ [ '<STR_LIT>' ] ) <EOL> else : <EOL> args . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> if '<STR_LIT>' in os . environ and '<STR_LIT>' not in args : <EOL> args . insert ( <NUM_LIT:0> , '<STR_LIT>' + os . environ [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in os . environ and '<STR_LIT>' not in args : <EOL> args . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> if '<STR_LIT>' in os . environ : <EOL> args . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> if '<STR_LIT>' in os . environ : <EOL> args . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> def pytest_addoption ( parser ) : <EOL> parser . addoption ( "<STR_LIT>" , action = "<STR_LIT>" , <EOL> help = "<STR_LIT>" % backends . keys ( ) ) <EOL> parser . addoption ( "<STR_LIT>" , action = "<STR_LIT:store_true>" , help = "<STR_LIT>" ) <EOL> parser . addoption ( "<STR_LIT>" , action = "<STR_LIT:store_true>" , help = "<STR_LIT>" ) <EOL> def pytest_collection_modifyitems ( items ) : <EOL> """<STR_LIT>""" <EOL> def cmp ( item1 , item2 ) : <EOL> def get_backend_param ( item ) : <EOL> try : <EOL> return item . callspec . getparam ( "<STR_LIT>" ) <EOL> except : <EOL> return '<STR_LIT>' <EOL> param1 = get_backend_param ( item1 ) <EOL> param2 = get_backend_param ( item2 ) <EOL> if param1 < param2 : <EOL> return - <NUM_LIT:1> <EOL> elif param1 > param2 : <EOL> return <NUM_LIT:1> <EOL> return <NUM_LIT:0> <EOL> items . sort ( cmp = cmp ) <EOL> @ pytest . fixture <EOL> def skip_cuda ( ) : <EOL> return None <EOL> @ pytest . fixture <EOL> def skip_opencl ( ) : <EOL> return None <EOL> @ pytest . fixture <EOL> def skip_sequential ( ) : <EOL> return None <EOL> @ pytest . fixture <EOL> def skip_openmp ( ) : <EOL> return None <EOL> @ pytest . fixture <EOL> def skip_greedy ( ) : <EOL> return None <EOL> @ pytest . fixture <EOL> def skip_lazy ( ) : <EOL> return None <EOL> def pytest_generate_tests ( metafunc ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in metafunc . fixturenames : <EOL> skip_backends = set ( ) <EOL> if hasattr ( metafunc . module , '<STR_LIT>' ) : <EOL> skip_backends = skip_backends . union ( <EOL> set ( metafunc . module . skip_backends ) ) <EOL> if hasattr ( metafunc . cls , '<STR_LIT>' ) : <EOL> skip_backends = skip_backends . union ( <EOL> set ( metafunc . cls . skip_backends ) ) <EOL> if metafunc . config . option . backend : <EOL> backend = set ( [ x . lower ( ) for x in metafunc . config . option . backend ] ) <EOL> else : <EOL> backend = set ( backends . keys ( ) ) <EOL> if hasattr ( metafunc . module , '<STR_LIT>' ) : <EOL> backend = backend . intersection ( set ( metafunc . module . backends ) ) <EOL> if hasattr ( metafunc . cls , '<STR_LIT>' ) : <EOL> backend = backend . intersection ( set ( metafunc . cls . backends ) ) <EOL> lazy = [ ] <EOL> if not ( '<STR_LIT>' in metafunc . fixturenames or <EOL> metafunc . config . option . lazy ) : <EOL> lazy . append ( '<STR_LIT>' ) <EOL> if not ( '<STR_LIT>' in metafunc . fixturenames or <EOL> metafunc . config . option . greedy ) : <EOL> lazy . append ( '<STR_LIT>' ) <EOL> backend = [ b for b in backend . difference ( skip_backends ) <EOL> if not '<STR_LIT>' + b in metafunc . fixturenames ] <EOL> params = list ( product ( backend , lazy ) ) <EOL> metafunc . parametrize ( '<STR_LIT>' , params or [ ( None , None ) ] , indirect = True , <EOL> ids = [ '<STR_LIT:->' . join ( p ) for p in params ] ) <EOL> @ pytest . fixture ( scope = '<STR_LIT>' ) <EOL> def backend ( request ) : <EOL> backend , lazy = request . param <EOL> try : <EOL> op2 . init ( backend = backend , lazy_evaluation = ( lazy == '<STR_LIT>' ) ) <EOL> except : <EOL> pytest . skip ( '<STR_LIT>' % backend ) <EOL> return backend </s>
