code: def test_cache_readonly():
      class Example:
          def __init__(self):
              self._cache = {}
              self.a = 0
  
          @cache_readonly
          def b(self):
              return 1
  
      ex = Example()
  
      # Try accessing/setting a readonly attribute
      assert_equal(ex.__dict__, dict(a=0, _cache={}))
  
      b = ex.b
      assert_equal(b, 1)
      assert_equal(
          ex.__dict__,
          dict(
              a=0,
              _cache=dict(
                  b=1,
              ),
          ),
      )
      # assert_equal(ex.__dict__, dict(a=0, b=1, _cache=dict(b=1)))
  
      with pytest.raises(AttributeError):
          ex.b = -1
  
      assert_equal(
          ex._cache,
          dict(
              b=1,
          ),
      )
  
imports: import pytest
  from numpy.testing import assert_equal
  from statsmodels.tools.decorators import cache_readonly, deprecated_alias
label_desc: Use image node_id 1 for calling a global function with example usage: test_cache_readonly() and returns: int