<s> import os <EOL> import shutil <EOL> import unittest <EOL> from subprocess import check_call , CalledProcessError , PIPE <EOL> class TestHookedIsFunctional ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestHookedIsFunctional , self ) . setUp ( ) <EOL> self . old_dir = os . getcwd ( ) <EOL> os . mkdir ( "<STR_LIT>" ) <EOL> os . chdir ( "<STR_LIT>" ) <EOL> check_call ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> os . chdir ( self . old_dir ) <EOL> self . hooked_binary = "<STR_LIT>" <EOL> self . git_root_dir = os . path . join ( os . getcwd ( ) , "<STR_LIT>" ) <EOL> def tearDown ( self ) : <EOL> shutil . rmtree ( self . git_root_dir ) <EOL> os . chdir ( self . old_dir ) <EOL> super ( TestHookedIsFunctional , self ) . tearDown ( ) <EOL> def test_hooked_installs_hooks_success ( self ) : <EOL> os . chdir ( "<STR_LIT:..>" ) <EOL> git_hooks_path = os . path . join ( self . git_root_dir , "<STR_LIT>" ) <EOL> current_hooks = os . listdir ( git_hooks_path ) <EOL> out = check_call ( [ self . hooked_binary , "<STR_LIT>" % ( self . git_root_dir ) ] ) <EOL> hooked_hooks = os . listdir ( git_hooks_path ) <EOL> different_hooks = set ( hooked_hooks ) - set ( current_hooks ) <EOL> self . assertEquals ( different_hooks , set ( [ "<STR_LIT:action>" , "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> def test_hooked_no_git_root ( self ) : <EOL> os . chdir ( "<STR_LIT:..>" ) <EOL> try : <EOL> out = check_call ( [ self . hooked_binary ] ) <EOL> self . assertEquals ( out , <NUM_LIT:0> , "<STR_LIT>" ) <EOL> except CalledProcessError : <EOL> pass <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
