code: def test_truncate(tmpfile):
      with open(tmpfile, "w") as fh:
          fh.write("spam and eggs")
  
      with portalocker.Lock(tmpfile, mode="a+") as fh:
          # Make sure we didn't overwrite the original text
          fh.seek(0)
          assert fh.read(13) == "spam and eggs"
  
      with portalocker.Lock(tmpfile, mode="w+") as fh:
          # Make sure we truncated the file
          assert fh.read() == ""
  
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 6 for calling a global function with example usage: test_truncate(tmpfile) without return types