<s> import os <EOL> import subprocess as sp <EOL> import tempfile <EOL> import unittest <EOL> from rosdep2 import main as rdmain <EOL> class Issue30TestCase ( unittest . TestCase ) : <EOL> def testIssue30 ( self ) : <EOL> return True <EOL> d = make_temp_dir ( ) <EOL> try : <EOL> cd ( d ) <EOL> script = '''<STR_LIT>''' <EOL> run_script ( '<STR_LIT>' , script ) <EOL> source ( '<STR_LIT>' ) <EOL> lookup = make_lookup ( ) <EOL> keys = rdmain . get_keys ( lookup , [ '<STR_LIT>' ] , recursive = True ) <EOL> expected = '''<STR_LIT>''' . split ( ) <EOL> self . assertEqual ( expected , sorted ( keys ) ) <EOL> finally : <EOL> sp . call ( [ '<STR_LIT>' , '<STR_LIT>' , d ] ) <EOL> def make_temp_dir ( ) : <EOL> return tempfile . mkdtemp ( ) <EOL> def cd ( d ) : <EOL> os . chdir ( d ) <EOL> def write_file ( filename , contents ) : <EOL> with open ( filename , '<STR_LIT:w>' ) as f : <EOL> f . write ( contents ) <EOL> def run_script ( filename , contents ) : <EOL> """<STR_LIT>""" <EOL> write_file ( filename , contents ) <EOL> os . chmod ( filename , <NUM_LIT> ) <EOL> p = sp . Popen ( [ os . path . join ( '<STR_LIT:.>' , filename ) ] , stdout = sp . PIPE ) <EOL> p . wait ( ) <EOL> return p . stdout . read ( ) <EOL> def source ( script ) : <EOL> """<STR_LIT>""" <EOL> pipe = sp . Popen ( "<STR_LIT>" % script , stdout = sp . PIPE , shell = True ) <EOL> data = pipe . communicate ( ) [ <NUM_LIT:0> ] <EOL> env = dict ( ( line . split ( "<STR_LIT:=>" , <NUM_LIT:1> ) for line in data . splitlines ( ) ) ) <EOL> os . environ . update ( env ) <EOL> def make_lookup ( ) : <EOL> """<STR_LIT>""" <EOL> import rosdep2 . sources_list as sl <EOL> import rosdep2 . lookup as rdl <EOL> sources_loader = sl . SourcesListLoader . create_default ( <EOL> sources_cache_dir = sl . get_sources_cache_dir ( ) , <EOL> verbose = True ) <EOL> return rdl . RosdepLookup . create_from_rospkg ( sources_loader = sources_loader ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
