Changeset 5853
- Timestamp:
- Oct 21, 2008, 11:08:05 AM (16 years ago)
- 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 4 4 5 5 from anuga.caching import * 6 6 from anuga.caching.dummy_classes_for_testing import Dummy, Dummy_memorytest 7 7 8 8 … … 37 37 38 38 39 class Dummy:40 def __init__(self, value, another):41 self.value = value42 self.another = another43 44 def copy(self):45 return Dummy(self.value, self.another)46 47 48 39 def clear_and_create_cache(Dummy, verbose=False): 40 49 41 a = cache(Dummy, 'clear', verbose=verbose) 50 51 42 a = cache(Dummy, args=(9,10), 52 43 verbose=verbose) … … 55 46 def retrieve_cache(Dummy, verbose=False): 56 47 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 59 55 60 56 … … 458 454 # The error message is 459 455 # 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): 461 460 """ 462 461 This test shows how instances can be created from cache 463 462 as long as input arguments are unchanged. 464 463 465 Such instances will have different id's and cannot be used as input464 Such instances will have different id's and cannot be currently be used as input 466 465 arguments in subsequent caches. However, this is still useful. 467 466 … … 493 492 # inside the caching dir and also at the anuga_core level, 494 493 # 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 496 497 def Xtest_objects_are_created_memory(self): 497 498 """ … … 512 513 513 514 # Make sure that class has been redefined to another address 514 #print515 #print 'Initial_addr ', initial_addr516 #print 'Redefined addr', `Dummy_memorytest`515 print 516 print 'Initial_addr ', initial_addr 517 print 'Redefined addr', `Dummy_memorytest` 517 518 msg = 'Redefined class ended up at same memory location as ' 518 519 msg += 'original class making this test irrelevant. Try to run ' … … 524 525 retrieve_cache(Dummy_memorytest, verbose=verbose) 525 526 526 # Define class Dummy_memorytest before any tests are run527 # to make sure it has a different memory address528 # to the one defined in test 'test_objects_are_created_memory'529 #class Dummy_memorytest:530 # def __init__(self, value, another):531 # self.value = value532 533 527 # Cache created for use with 'test_objects_are_created_memory' 534 #initial_addr = `Dummy_memorytest`535 #clear_and_create_cache(Dummy_memorytest, verbose=False)528 initial_addr = `Dummy_memorytest` 529 clear_and_create_cache(Dummy_memorytest, verbose=False) 536 530 537 531
Note: See TracChangeset
for help on using the changeset viewer.