code: def test_hard_memory_limit_cgroups(monkeypatch):
      builtin_open = builtins.open
  
      def myopen(path, *args, **kwargs):
          if path == "/sys/fs/cgroup/memory/memory.limit_in_bytes":
              # Absurdly low, unlikely to match real value
              return io.StringIO("20")
          return builtin_open(path, *args, **kwargs)
  
      monkeypatch.setattr(builtins, "open", myopen)
      monkeypatch.setattr(sys, "platform", "linux")
  
      limit = memory_limit()
      assert limit == 20
  
file_path: distributed/distributed/tests/test_system.py
imports: from __future__ import annotations
  import builtins
  import io
  import sys
  import psutil
  import pytest
  from distributed.compatibility import MACOS
  from distributed.system import memory_limit
label_desc: Use image node_id 2 for calling a global function with example usage: test_hard_memory_limit_cgroups(monkeypatch) and returns: builtin_open, io