<s> import os <EOL> import unittest <EOL> import tempfile <EOL> import shutil <EOL> try : <EOL> from catkin . package_version import _replace_version , update_versions <EOL> except ImportError as impe : <EOL> raise ImportError ( <EOL> '<STR_LIT>' % str ( impe ) ) <EOL> class PackageVersionTest ( unittest . TestCase ) : <EOL> def test_replace_version ( self ) : <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> _replace_version ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> _replace_version ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . assertRaises ( RuntimeError , _replace_version , "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertRaises ( RuntimeError , _replace_version , "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_update_versions ( self ) : <EOL> try : <EOL> root_dir = tempfile . mkdtemp ( ) <EOL> sub_dir = os . path . join ( root_dir , '<STR_LIT>' ) <EOL> with open ( os . path . join ( root_dir , "<STR_LIT>" ) , '<STR_LIT:w>' ) as fhand : <EOL> fhand . write ( '<STR_LIT>' ) <EOL> os . makedirs ( os . path . join ( sub_dir ) ) <EOL> with open ( os . path . join ( sub_dir , "<STR_LIT>" ) , '<STR_LIT:w>' ) as fhand : <EOL> fhand . write ( '<STR_LIT>' ) <EOL> update_versions ( [ root_dir , sub_dir ] , "<STR_LIT>" ) <EOL> with open ( os . path . join ( root_dir , "<STR_LIT>" ) , '<STR_LIT:r>' ) as fhand : <EOL> contents = fhand . read ( ) <EOL> self . assertEqual ( '<STR_LIT>' , contents ) <EOL> with open ( os . path . join ( sub_dir , "<STR_LIT>" ) , '<STR_LIT:r>' ) as fhand : <EOL> contents = fhand . read ( ) <EOL> self . assertEqual ( '<STR_LIT>' , contents ) <EOL> finally : <EOL> shutil . rmtree ( root_dir ) </s>
