code: def test_secure_write_unix():
      directory = tempfile.mkdtemp()
      fname = os.path.join(directory, "check_perms")
      try:
          with secure_write(fname) as f:
              f.write("test 1")
          mode = os.stat(fname).st_mode
          assert (
              stat.S_IMODE(mode) & 0o7677
          ) == 0o0600  # tolerate owner-execute bit
          with open(fname, encoding="utf-8") as f:
              assert f.read() == "test 1"
  
          # Try changing file permissions ahead of time
          os.chmod(fname, 0o755)
          with secure_write(fname) as f:
              f.write("test 2")
          mode = os.stat(fname).st_mode
          assert (
              stat.S_IMODE(mode) & 0o7677
          ) == 0o0600  # tolerate owner-execute bit
          with open(fname, encoding="utf-8") as f:
              assert f.read() == "test 2"
      finally:
          shutil.rmtree(directory)
  
imports: from __future__ import annotations
  import os
  import re
  import shutil
  import site
  import stat
  import subprocess
  import sys
  import tempfile
  import warnings
  from unittest.mock import patch
  import pytest
  from platformdirs import __version_info__
  from jupyter_core import paths
  from jupyter_core.paths import UF_HIDDEN, _win32_restrict_file_to_user_ctypes, exists, is_file_hidden, is_hidden, issue_insecure_write_warning, jupyter_config_dir, jupyter_config_path, jupyter_data_dir, jupyter_path, jupyter_runtime_dir, prefer_environment_over_user, secure_write
label_desc: Use image node_id 44 for calling a global function with example usage: test_secure_write_unix() without return types