code: def test_shared(tmpfile):
      with open(tmpfile, "w") as fh:
          fh.write("spam and eggs")
  
      f = open(tmpfile, "r")
      portalocker.lock(f, portalocker.LOCK_SH | portalocker.LOCK_NB)
  
      # Make sure we can read the locked file
      with open(tmpfile, "r") as fh2:
          portalocker.lock(
              fh2, portalocker.LOCK_SH | portalocker.LOCK_NB
          )
          assert fh2.read() == "spam and eggs"
  
      # Make sure we can't write the locked file
      with pytest.raises(portalocker.LockException):
          with open(tmpfile, "w+") as fh2:
              portalocker.lock(
                  fh2, portalocker.LOCK_EX | portalocker.LOCK_NB
              )
              fh2.write("surprise and fear")
  
      # Make sure we can explicitly unlock the file
      portalocker.unlock(f)
      f.close()
  
file_path: catboost/contrib/python/portalocker/py2/tests/tests.py
imports: from __future__ import print_function
  from __future__ import with_statement
  import pytest
  import portalocker
label_desc: Use image node_id 13 for calling a global function with example usage: test_shared(tmpfile) without return types