code: def test_ref_switch():
      import warnings
  
      col = columns.RefBytesColumn()
  
      def rw(size):
          st = RamStorage()
  
          f = st.create_file("test")
          cw = col.writer(f)
          for i in xrange(size):
              cw.add(i, hex(i).encode("latin1"))
          cw.finish(size)
          length = f.tell()
          f.close()
  
          f = st.open_file("test")
          cr = col.reader(f, 0, length, size)
          for i in xrange(size):
              v = cr[i]
              # Column ignores additional unique values after 65535
              if i <= 65535 - 1:
                  assert v == hex(i).encode("latin1")
              else:
                  assert v == b("")
          f.close()
  
      rw(255)
  
      # warnings.catch_warnings is not available in Python 2.5
      if hasattr(warnings, "catch_warnings"):
          # Column warns on additional unique values after 65535
          with warnings.catch_warnings(record=True) as w:
              # Cause all warnings to always be triggered.
              warnings.simplefilter("always")
              rw(65537)
  
              assert len(w) == 2
              assert issubclass(w[-1].category, UserWarning)
  
file_path: whoosh/tests/test_columns.py
imports: from __future__ import with_statement
  import inspect, random, sys
  from whoosh import columns, fields, query
  from whoosh.codec.whoosh3 import W3Codec
  from whoosh.compat import b, u, BytesIO, bytes_type, text_type
  from whoosh.compat import izip, xrange, dumps, loads
  from whoosh.filedb import compound
  from whoosh.filedb.filestore import RamStorage
  from whoosh.util.testing import TempIndex, TempStorage
label_desc: Use image node_id 9 for calling a global function with example usage: test_ref_switch() without return types