<s> import tempfile <EOL> import shutil <EOL> import os <EOL> def assertEventEquals ( self , expected , actual ) : <EOL> """<STR_LIT>""" <EOL> expected = dict ( expected ) <EOL> del expected [ '<STR_LIT>' ] <EOL> actual = dict ( actual ) <EOL> del actual [ '<STR_LIT>' ] <EOL> self . assertEquals ( expected , actual ) <EOL> class Matcher ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , compare ) : <EOL> self . compare = compare <EOL> def __eq__ ( self , other ) : <EOL> return self . compare ( other ) <EOL> def __repr__ ( self ) : <EOL> return repr ( self . compare ) <EOL> def any ( _ ) : <EOL> """<STR_LIT>""" <EOL> return True <EOL> def about ( x , p = <NUM_LIT:0> ) : <EOL> fmt = '<STR_LIT>' % p <EOL> return Matcher ( lambda t : fmt % x == fmt % t ) <EOL> def between ( x , y ) : <EOL> return Matcher ( lambda t : t > x and t < y ) <EOL> ANY = Matcher ( any ) <EOL> class TempDirectory ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , suffix = '<STR_LIT>' , prefix = '<STR_LIT>' , dir = None , change = True ) : <EOL> self . suffix = suffix <EOL> self . prefix = prefix <EOL> self . dir = dir <EOL> self . change = change <EOL> def __enter__ ( self ) : <EOL> self . name = tempfile . mkdtemp ( self . suffix , self . prefix , self . dir ) <EOL> if self . change : <EOL> self . oldpwd = os . getcwd ( ) <EOL> os . chdir ( self . name ) <EOL> return self <EOL> def __exit__ ( self , * excinfo ) : <EOL> if self . change : <EOL> os . chdir ( self . oldpwd ) <EOL> shutil . rmtree ( self . name ) </s>
