'Execute a hook script, passing a context'

def test_run_script_with_context(self):

    hook_path = os.path.join(self.hooks_path, 'post_gen_project.sh')
    if sys.platform.startswith('win'):
        post = 'post_gen_project.bat'
        with open(os.path.join(self.hooks_path, post), 'w') as f:
            f.write('@echo    off\n')
            f.write('\n')
            f.write('echo    post    generation    hook\n')
            f.write('echo.    >{{cookiecutter.file}}\n')
    else:
        with open(hook_path, 'w') as fh:
            fh.write('#!/bin/bash\n')
            fh.write('\n')
            fh.write("echo    'post    generation    hook';\n")
            fh.write("touch    'shell_post.txt'\n")
            fh.write("touch    '{{cookiecutter.file}}'\n")
            os.chmod(hook_path, (os.stat(hook_path).st_mode | stat.S_IXUSR))
    hooks.run_script_with_context(os.path.join(self.hooks_path, self.post_hook), 'tests', {'cookiecutter': {'file': 'context_post.txt'}})
    assert os.path.isfile('tests/context_post.txt')
    assert ('tests' not in os.getcwd())
