class_docstr: Test zipapp module functionality.
class_docstr_tok: ["Test","zipapp","module","functionality","."]
code: def test_main_written(self):
      # Test that the __main__.py is written correctly.
      source = self.tmpdir / "source"
      source.mkdir()
      (source / "foo.py").touch()
      target = self.tmpdir / "source.pyz"
      zipapp.create_archive(str(source), str(target), main="pkg.mod:fn")
      with zipfile.ZipFile(str(target), "r") as z:
          self.assertIn("__main__.py", z.namelist())
          self.assertIn(b"pkg.mod.fn()", z.read("__main__.py"))
  
imports: import io
  import pathlib
  import stat
  import sys
  import tempfile
  import unittest
  import zipapp
  import zipfile
  from test.support import requires_zlib
  from test.support import os_helper
  from unittest.mock import patch
label_desc: Use image node_id 12 for calling the ZipAppTest obj's underlying member method code with example usage: obj.test_main_written() without return types