class_docstr: Test zipapp module functionality.
class_docstr_tok: ["Test","zipapp","module","functionality","."]
code: def test_main_only_written_once(self):
      # Test that we don't write multiple __main__.py files.
      # The initial implementation had this bug; zip files allow
      # multiple entries with the same name
      source = self.tmpdir / "source"
      source.mkdir()
      # Write 2 files, as the original bug wrote __main__.py
      # once for each file written :-(
      # See http://bugs.python.org/review/23491/diff/13982/Lib/zipapp.py#newcode67Lib/zipapp.py:67
      # (line 67)
      (source / "foo.py").touch()
      (source / "bar.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.assertEqual(1, z.namelist().count("__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 13 for calling the ZipAppTest obj's underlying member method code with example usage: obj.test_main_only_written_once() without return types