Changeset 4272


Ignore:
Timestamp:
Feb 21, 2007, 9:45:58 AM (18 years ago)
Author:
duncan
Message:

added test, looking at instances passed in.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/caching/test_caching.py

    r3715 r4272  
    2020  return(B)
    2121
    22 
    23 
    24 
    25 
    26 
     22class Dummy:
     23  def __init__(self,value, another):
     24    self.value = value
    2725
    2826class Test_Caching(unittest.TestCase):
     
    300298
    301299
     300    def Will_fail_test_objects(self):
     301      """
     302      This test shows how instances can't be effectively cached.
     303      myhash uses hash which uses id which uses the memory address.
     304      """
     305      verbose = True
     306      verbose = False
     307
     308      for i in range(2):
     309        if verbose: print "clear cache"
     310        a = cache(Dummy,'clear')     
     311        if verbose: print "cache for first time"
     312        a = cache(Dummy,args=(9,10) ,verbose=verbose)
     313        hash_value = myhash(a)
     314        #print "hash_value",hash_value
     315        if verbose: print "cache for second time"
     316        a = cache(Dummy,args=(9,10) ,verbose=verbose)
     317        #print "myhash(a)",myhash(a)
     318        assert hash_value == myhash(a)
     319
     320     
     321       
    302322
    303323
Note: See TracChangeset for help on using the changeset viewer.