<s> import sys <EOL> import gitimport <EOL> import unittest <EOL> import inspect <EOL> import pygit2 <EOL> class GitImporterTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> gitimport . add_gitimporter_path_hook ( ) <EOL> self . repo = repo = pygit2 . Repository ( '<STR_LIT:.>' ) <EOL> self . commit_sha = repo . revparse_single ( '<STR_LIT>' ) . hex <EOL> sys . path . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> sys . path . insert ( <NUM_LIT:0> , gitimport . repository_path ( self . repo , in_repo_path = '<STR_LIT>' ) ) <EOL> def test_convenience ( self ) : <EOL> expected_path = sys . path . pop ( <NUM_LIT:0> ) <EOL> sys . path . insert ( <NUM_LIT:0> , gitimport . repository_path ( self . repo , in_repo_path = '<STR_LIT>' ) ) <EOL> self . assertEqual ( expected_path , sys . path . pop ( <NUM_LIT:0> ) ) <EOL> sys . path . insert ( <NUM_LIT:0> , gitimport . repository_path ( '<STR_LIT:.>' , in_repo_path = '<STR_LIT>' ) ) <EOL> self . assertEqual ( expected_path , sys . path . pop ( <NUM_LIT:0> ) ) <EOL> gitimport . add_repository_to_path ( '<STR_LIT:.>' , in_repo_path = '<STR_LIT>' ) <EOL> self . assertEqual ( expected_path , sys . path . pop ( <NUM_LIT:0> ) ) <EOL> sys . path . insert ( <NUM_LIT:0> , expected_path ) <EOL> def test_import ( self ) : <EOL> import hello <EOL> self . assertTrue ( inspect . ismodule ( hello ) ) <EOL> self . assertIsNotNone ( hello . say_hello ) <EOL> self . assertEqual ( hello . __git_commit__ , self . commit_sha ) <EOL> def test_module_import ( self ) : <EOL> import mod <EOL> self . assertTrue ( inspect . ismodule ( mod ) ) <EOL> self . assertEqual ( mod . __git_commit__ , self . commit_sha ) <EOL> def test_submodule_import ( self ) : <EOL> from mod import submod_hello <EOL> self . assertIsNotNone ( submod_hello ) <EOL> def test_parent_import ( self ) : <EOL> from mod . submod import parent_importer <EOL> self . assertTrue ( inspect . ismodule ( parent_importer ) ) <EOL> def test_importerror ( self ) : <EOL> try : <EOL> import does_not_exists <EOL> except ImportError : <EOL> pass <EOL> def test_repository_path ( self ) : <EOL> path = gitimport . repository_path ( self . repo ) <EOL> self . assertEqual ( path , self . repo . path + "<STR_LIT:@>" + self . commit_sha + '<STR_LIT:/>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
