code: def test_pre_commit_hook(tmpdir):
      tmp_ipynb = str(tmpdir.join("nb with spaces.ipynb"))
      tmp_py = str(tmpdir.join("nb with spaces.py"))
      nb = new_notebook(cells=[])
  
      git = git_in_tmpdir(tmpdir)
      hook = str(tmpdir.join(".git/hooks/pre-commit"))
      with open(hook, "w") as fp:
          fp.write(
              "#!/bin/sh\n" "jupytext --to py:light --pre-commit\n"
          )
  
      st = os.stat(hook)
      os.chmod(hook, st.st_mode | stat.S_IEXEC)
  
      write(nb, tmp_ipynb)
      assert os.path.isfile(tmp_ipynb)
      assert not os.path.isfile(tmp_py)
  
      git("add", "nb with spaces.ipynb")
      git("status")
      git("commit", "-m", "created")
      git("status")
  
      assert "nb with spaces.py" in git(
          "ls-tree", "-r", "main", "--name-only"
      )
      assert os.path.isfile(tmp_py)
  
file_path: jupytext/tests/external/pre_commit/test_pre_commit_scripts.py
imports: import os
  import stat
  import unittest.mock
  import pytest
  from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook
  from jupytext import read, write
  from jupytext.cli import jupytext, system
  from jupytext.compare import compare_cells, compare_notebooks
label_desc: Use image node_id 3 for calling a global function with example usage: test_pre_commit_hook(tmpdir) without return types