code: def test_random_hash():
      from string import ascii_letters as domain
  
      times = 1000
      minlen = 1
      maxlen = len(domain)
  
      def randstring():
          s = "".join(
              random.sample(domain, random.randint(minlen, maxlen))
          )
          return b(s)
  
      with TempStorage("randomhash") as st:
          samp = dict(
              (randstring(), randstring()) for _ in xrange(times)
          )
  
          hw = HashWriter(st.create_file("test.hsh"))
          for k, v in iteritems(samp):
              hw.add(k, v)
          hw.close()
  
          keys = list(samp.keys())
          random.shuffle(keys)
          hr = HashReader.open(st, "test.hsh")
          for k in keys:
              assert hr[k] == samp[k]
          hr.close()
  
file_path: whoosh/tests/test_tables.py
imports: from __future__ import with_statement
  import random
  from whoosh.compat import b, xrange, iteritems
  from whoosh.filedb.filestore import RamStorage
  from whoosh.filedb.filetables import HashReader, HashWriter
  from whoosh.filedb.filetables import OrderedHashWriter, OrderedHashReader
  from whoosh.util.testing import TempStorage
label_desc: Use image node_id 5 for calling a global function with example usage: test_random_hash() and returns: b