<s> from __future__ import unicode_literals <EOL> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> if sys . version_info < ( <NUM_LIT:2> , <NUM_LIT:7> , <NUM_LIT:0> ) : <EOL> import unittest2 as unittest <EOL> else : <EOL> import unittest <EOL> import shutil <EOL> import six <EOL> class Examples ( unittest . TestCase ) : <EOL> def _test_pyfile ( self , pyfile , want = True , comparator = None , expectexit = False ) : <EOL> l = locals ( ) <EOL> l [ '<STR_LIT>' ] = lambda x : None <EOL> with open ( pyfile ) as fp : <EOL> pycode = compile ( fp . read ( ) , pyfile , '<STR_LIT>' ) <EOL> try : <EOL> result = six . exec_ ( pycode , globals ( ) , l ) <EOL> got = locals ( ) [ '<STR_LIT>' ] <EOL> if not comparator : <EOL> comparator = self . assertEqual <EOL> comparator ( want , got ) <EOL> except SystemExit as e : <EOL> if not expectexit : <EOL> raise e <EOL> def test_firststep ( self ) : <EOL> self . _test_pyfile ( "<STR_LIT>" ) <EOL> os . unlink ( "<STR_LIT>" ) <EOL> def test_usage ( self ) : <EOL> shutil . copy2 ( "<STR_LIT>" , os . getcwd ( ) ) <EOL> self . _test_pyfile ( "<STR_LIT>" ) <EOL> os . unlink ( "<STR_LIT>" ) <EOL> def test_argparse ( self ) : <EOL> _stdout = sys . stdout <EOL> try : <EOL> devnull = open ( os . devnull , "<STR_LIT:w>" ) <EOL> sys . stdout = devnull <EOL> self . _test_pyfile ( "<STR_LIT>" , expectexit = True ) <EOL> finally : <EOL> sys . stdout = _stdout <EOL> devnull . close ( ) <EOL> os . unlink ( "<STR_LIT>" ) <EOL> def test_pyfile ( self ) : <EOL> shutil . copy2 ( "<STR_LIT>" , os . getcwd ( ) ) <EOL> shutil . copy2 ( "<STR_LIT>" , os . getcwd ( ) ) <EOL> shutil . copy2 ( "<STR_LIT>" , os . getcwd ( ) ) <EOL> shutil . copy2 ( "<STR_LIT>" , os . getcwd ( ) ) <EOL> self . _test_pyfile ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . _test_pyfile ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> os . unlink ( "<STR_LIT>" ) <EOL> os . unlink ( "<STR_LIT>" ) <EOL> os . unlink ( "<STR_LIT>" ) <EOL> os . unlink ( "<STR_LIT>" ) </s>
