code: def test_slice_fileobj_file(self):
      self.content = b"RANDOM self.content uauabciabeubahveb" * 1024
  
      with SoftTemporaryDirectory() as tmpdir:
          filepath = os.path.join(tmpdir, "file.bin")
          with open(filepath, "wb+") as f:
              f.write(self.content)
          with open(filepath, "rb") as fileobj:
              prev_pos = fileobj.tell()
              # Test read
              with SliceFileObj(
                  fileobj, seek_from=24, read_limit=18
              ) as fileobj_slice:
                  self.assertEqual(fileobj_slice.tell(), 0)
                  self.assertEqual(
                      fileobj_slice.read(), self.content[24:42]
                  )
                  self.assertEqual(fileobj_slice.tell(), 18)
                  self.assertEqual(fileobj_slice.read(), b"")
                  self.assertEqual(fileobj_slice.tell(), 18)
  
              self.assertEqual(fileobj.tell(), prev_pos)
  
              with SliceFileObj(
                  fileobj, seek_from=0, read_limit=990
              ) as fileobj_slice:
                  self.assertEqual(fileobj_slice.tell(), 0)
                  self.assertEqual(
                      fileobj_slice.read(200), self.content[0:200]
                  )
                  self.assertEqual(
                      fileobj_slice.read(500), self.content[200:700]
                  )
                  self.assertEqual(
                      fileobj_slice.read(200), self.content[700:900]
                  )
                  self.assertEqual(
                      fileobj_slice.read(200), self.content[900:990]
                  )
                  self.assertEqual(fileobj_slice.read(200), b"")
  
              # Test seek with whence = os.SEEK_SET
              with SliceFileObj(
                  fileobj, seek_from=100, read_limit=100
              ) as fileobj_slice:
                  self.assertEqual(fileobj_slice.tell(), 0)
                  fileobj_slice.seek(2, os.SEEK_SET)
                  self.assertEqual(fileobj_slice.tell(), 2)
                  self.assertEqual(fileobj_slice.fileobj.tell(), 102)
                  fileobj_slice.seek(-4, os.SEEK_SET)
                  self.assertEqual(fileobj_slice.tell(), 0)
                  self.assertEqual(fileobj_slice.fileobj.tell(), 100)
                  fileobj_slice.seek(100 + 4, os.SEEK_SET)
                  self.assertEqual(fileobj_slice.tell(), 100)
                  self.assertEqual(fileobj_slice.fileobj.tell(), 200)
  
              # Test seek with whence = os.SEEK_CUR
              with SliceFileObj(
                  fileobj, seek_from=100, read_limit=100
              ) as fileobj_slice:
                  self.assertEqual(fileobj_slice.tell(), 0)
                  fileobj_slice.seek(-5, os.SEEK_CUR)
                  self.assertEqual(fileobj_slice.tell(), 0)
                  self.assertEqual(fileobj_slice.fileobj.tell(), 100)
                  fileobj_slice.seek(50, os.SEEK_CUR)
                  self.assertEqual(fileobj_slice.tell(), 50)
                  self.assertEqual(fileobj_slice.fileobj.tell(), 150)
                  fileobj_slice.seek(100, os.SEEK_CUR)
                  self.assertEqual(fileobj_slice.tell(), 100)
                  self.assertEqual(fileobj_slice.fileobj.tell(), 200)
                  fileobj_slice.seek(-300, os.SEEK_CUR)
                  self.assertEqual(fileobj_slice.tell(), 0)
                  self.assertEqual(fileobj_slice.fileobj.tell(), 100)
  
              # Test seek with whence = os.SEEK_END
              with SliceFileObj(
                  fileobj, seek_from=100, read_limit=100
              ) as fileobj_slice:
                  self.assertEqual(fileobj_slice.tell(), 0)
                  fileobj_slice.seek(-5, os.SEEK_END)
                  self.assertEqual(fileobj_slice.tell(), 95)
                  self.assertEqual(fileobj_slice.fileobj.tell(), 195)
                  fileobj_slice.seek(50, os.SEEK_END)
                  self.assertEqual(fileobj_slice.tell(), 100)
                  self.assertEqual(fileobj_slice.fileobj.tell(), 200)
                  fileobj_slice.seek(-200, os.SEEK_END)
                  self.assertEqual(fileobj_slice.tell(), 0)
                  self.assertEqual(fileobj_slice.fileobj.tell(), 100)
  
file_path: huggingface_hub/tests/test_lfs.py
imports: import os
  import unittest
  from hashlib import sha256
  from io import BytesIO
  from huggingface_hub.lfs import SliceFileObj, UploadInfo
  from huggingface_hub.utils import SoftTemporaryDirectory
label_desc: Use image node_id 3 for calling the TestSliceFileObj obj's underlying member method code with example usage: obj.test_slice_fileobj_file() without return types