Changeset 5853


Ignore:
Timestamp:
Oct 21, 2008, 11:08:05 AM (16 years ago)
Author:
ole
Message:

Work towards testing caching with instances as inputs.
Test fails deliberately at the moment.

Location:
anuga_core/source/anuga/caching
Files:
1 added
1 edited

Legend:

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

    r5851 r5853  
    44
    55from anuga.caching import *
    6 
     6from anuga.caching.dummy_classes_for_testing import Dummy, Dummy_memorytest
    77
    88
     
    3737 
    3838 
    39 class Dummy:
    40   def __init__(self, value, another):
    41     self.value = value
    42     self.another = another
    43    
    44   def copy(self):
    45     return Dummy(self.value, self.another)
    46    
    47 
    4839def clear_and_create_cache(Dummy, verbose=False):
     40
    4941  a = cache(Dummy, 'clear', verbose=verbose)
    50        
    5142  a = cache(Dummy, args=(9,10),
    5243            verbose=verbose)
     
    5546def retrieve_cache(Dummy, verbose=False):
    5647  if verbose: print 'Check that cache is there'
    57   assert cache(Dummy, args=(9,10), test=1,
    58                verbose=verbose)     
     48 
     49  X = cache(Dummy, args=(9,10), test=1,
     50            verbose=verbose)     
     51           
     52  msg = 'Cached value was not found'
     53  assert X is not None, msg
     54
    5955     
    6056
     
    458454    # The error message is
    459455    # PicklingError: Can't pickle test_caching.Dummy: it's not the same object as test_caching.Dummy
    460     def Xtest_objects_are_created(self):
     456    #
     457    # This problem was fixed by moving the class into the separate module
     458   
     459    def test_objects_are_created(self):
    461460      """
    462461      This test shows how instances can be created from cache
    463462      as long as input arguments are unchanged.
    464463
    465       Such instances will have different id's and cannot be used as input
     464      Such instances will have different id's and cannot be currently be used as input
    466465      arguments in subsequent caches. However, this is still useful.
    467466
     
    493492    #             inside the caching dir and also at the anuga_core level,
    494493    #             it won't pass at the anuga_core/source/anuga level.
    495     # See  message above.
     494    # It may have to do with the comments above.
     495    #
     496    # But this is probably not so important, really
    496497    def Xtest_objects_are_created_memory(self):
    497498      """
     
    512513
    513514      # Make sure that class has been redefined to another address
    514       #print
    515       #print 'Initial_addr  ', initial_addr
    516       #print 'Redefined addr', `Dummy_memorytest`
     515      print
     516      print 'Initial_addr  ', initial_addr
     517      print 'Redefined addr', `Dummy_memorytest`
    517518      msg = 'Redefined class ended up at same memory location as '
    518519      msg += 'original class making this test irrelevant. Try to run '
     
    524525      retrieve_cache(Dummy_memorytest, verbose=verbose)     
    525526         
    526 # Define class Dummy_memorytest before any tests are run
    527 # to make sure it has a different memory address
    528 # to the one defined in test 'test_objects_are_created_memory'
    529 #class Dummy_memorytest:
    530 #  def __init__(self, value, another):
    531 #    self.value = value     
    532 
    533527# Cache created for use with 'test_objects_are_created_memory'
    534 #initial_addr = `Dummy_memorytest`
    535 #clear_and_create_cache(Dummy_memorytest, verbose=False)
     528initial_addr = `Dummy_memorytest`
     529clear_and_create_cache(Dummy_memorytest, verbose=False)
    536530 
    537531     
Note: See TracChangeset for help on using the changeset viewer.