code: def test_apply_black_on_python_notebooks(
      tmpdir, cwd_tmpdir, ipynb_py_file
  ):
      if "cell metadata" in ipynb_py_file:
          pytest.skip()
      copyfile(ipynb_py_file, "notebook.ipynb")
  
      jupytext(args=["notebook.ipynb", "--to", "py:percent"])
      system("black", "notebook.py")
      jupytext(args=["notebook.py", "--to", "ipynb", "--update"])
  
      nb1 = read(ipynb_py_file)
      nb2 = read("notebook.ipynb")
      nb3 = read("notebook.py")
  
      assert len(nb1.cells) == len(nb2.cells)
      assert len(nb1.cells) == len(nb3.cells)
      for c1, c2 in zip(nb1.cells, nb2.cells):
          # same content (almost)
          assert black_invariant(c1.source) == black_invariant(
              c2.source
          )
          # python representation is pep8
          assert "lines_to_next_cell" not in c2.metadata
          # outputs are preserved
          assert c1.cell_type == c2.cell_type
          if c1.cell_type == "code":
              compare(c1.outputs, c2.outputs)
  
      compare(nb1.metadata, nb2.metadata)
  
imports: import os
  from copy import deepcopy
  from shutil import copyfile
  import pytest
  from nbformat.v4.nbbase import new_code_cell, new_notebook
  from jupytext import read, write
  from jupytext.cli import jupytext, pipe_notebook, system
  from jupytext.combine import black_invariant
  from jupytext.compare import compare, compare_cells, compare_notebooks
  from jupytext.header import _DEFAULT_NOTEBOOK_METADATA
label_desc: Use image node_id 1 for calling a global function with example usage: test_apply_black_on_python_notebooks(tmpdir, cwd_tmpdir, ipynb_py_file) without return types