<s> import os <EOL> import urllib <EOL> import zipfile <EOL> import subprocess <EOL> CACHE_FOLDER = '<STR_LIT>' <EOL> VSPEC_FOLDER = os . path . join ( CACHE_FOLDER , '<STR_LIT>' ) <EOL> VSPEC_RUNNER = os . path . join ( VSPEC_FOLDER , '<STR_LIT>' ) <EOL> TEST_DIR = '<STR_LIT:test>' <EOL> class IntegrationTestFile ( object ) : <EOL> def __init__ ( self , path ) : <EOL> self . path = path <EOL> def run ( self ) : <EOL> output = subprocess . check_output ( [ VSPEC_RUNNER , '<STR_LIT:.>' , VSPEC_FOLDER , self . path ] ) <EOL> for line in output . splitlines ( ) : <EOL> if line . startswith ( b'<STR_LIT>' ) or line . startswith ( b'<STR_LIT>' ) : <EOL> print ( output ) <EOL> assert False <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( type ( self ) , self . path ) <EOL> def pytest_configure ( config ) : <EOL> if not os . path . isdir ( CACHE_FOLDER ) : <EOL> os . mkdir ( CACHE_FOLDER ) <EOL> if not os . path . exists ( VSPEC_FOLDER ) : <EOL> url = '<STR_LIT>' <EOL> name , hdrs = urllib . urlretrieve ( url ) <EOL> z = zipfile . ZipFile ( name ) <EOL> for n in z . namelist ( ) : <EOL> dest = os . path . join ( CACHE_FOLDER , n ) <EOL> destdir = os . path . dirname ( dest ) <EOL> if not os . path . isdir ( destdir ) : <EOL> os . makedirs ( destdir ) <EOL> data = z . read ( n ) <EOL> if not os . path . isdir ( dest ) : <EOL> with open ( dest , '<STR_LIT:w>' ) as f : <EOL> f . write ( data ) <EOL> z . close ( ) <EOL> os . chmod ( VSPEC_RUNNER , <NUM_LIT> ) <EOL> def pytest_generate_tests ( metafunc ) : <EOL> """<STR_LIT>""" <EOL> def collect_tests ( ) : <EOL> for f in os . listdir ( TEST_DIR ) : <EOL> if f . endswith ( '<STR_LIT>' ) : <EOL> yield IntegrationTestFile ( os . path . join ( TEST_DIR , f ) ) <EOL> metafunc . parametrize ( '<STR_LIT>' , list ( collect_tests ( ) ) ) </s>
