Changeset 9489


Ignore:
Timestamp:
Jan 22, 2015, 4:22:28 PM (10 years ago)
Author:
steve
Message:

Changed function name to easier avoid problems with nosetest

File:
1 edited

Legend:

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

    r8820 r9489  
    463463      set_option('compression', compression)
    464464    except:
    465       test_error('Set option failed')     
     465      log_test_error('Set option failed')     
    466466
    467467  try:
     
    505505    Depfile.write('We are the knights who say NI!')
    506506    Depfile.close()
    507     test_OK('Wrote file %s' %DepFN)
     507    log_test_OK('Wrote file %s' %DepFN)
    508508  except:
    509     test_error('Could not open file %s for writing - check your environment' \
     509    log_test_error('Could not open file %s for writing - check your environment' \
    510510               % DepFN)
    511511
     
    515515    set_option('savestat',0)
    516516    assert(options['savestat'] == 0)
    517     test_OK('Set option')
     517    log_test_OK('Set option')
    518518  except:
    519     test_error('Set option failed')   
     519    log_test_error('Set option failed')   
    520520   
    521521  # Make some test input arguments
     
    544544                   verbose=verbose, compression=comp)
    545545      if comp:                   
    546         test_OK('Caching evaluation with compression')
     546        log_test_OK('Caching evaluation with compression')
    547547      else:     
    548         test_OK('Caching evaluation without compression')     
     548        log_test_OK('Caching evaluation without compression')     
    549549    except:
    550550      if comp:
    551         test_error('Caching evaluation with compression failed - try caching.test(compression=0)')
     551        log_test_error('Caching evaluation with compression failed - try caching.test(compression=0)')
    552552      else:
    553         test_error('Caching evaluation failed - try caching.test(verbose=1)')
     553        log_test_error('Caching evaluation failed - try caching.test(verbose=1)')
    554554
    555555    # Retrieve
     
    560560
    561561      if comp:                   
    562         test_OK('Caching retrieval with compression')
     562        log_test_OK('Caching retrieval with compression')
    563563      else:     
    564         test_OK('Caching retrieval without compression')     
     564        log_test_OK('Caching retrieval without compression')     
    565565    except:
    566566      if comp:
    567         test_error('Caching retrieval with compression failed - try caching.test(compression=0)')
     567        log_test_error('Caching retrieval with compression failed - try caching.test(compression=0)')
    568568      else:                                     
    569         test_error('Caching retrieval failed - try caching.test(verbose=1)')
     569        log_test_error('Caching retrieval failed - try caching.test(verbose=1)')
    570570
    571571    # Reference result
     
    575575    if T1 == T2 and T2 == T3:
    576576      if comp:
    577         test_OK('Basic caching functionality (with compression)')
     577        log_test_OK('Basic caching functionality (with compression)')
    578578      else:
    579         test_OK('Basic caching functionality (without compression)')
     579        log_test_OK('Basic caching functionality (without compression)')
    580580    else:
    581       test_error('Cached result does not match computed result')
     581      log_test_error('Cached result does not match computed result')
    582582
    583583
     
    588588                 return_filename=1)   
    589589    assert(FN[:2] == 'f[')
    590     test_OK('Return of cache filename')
     590    log_test_OK('Return of cache filename')
    591591  except:
    592     test_error('Return of cache filename failed')
     592    log_test_error('Return of cache filename failed')
    593593
    594594  # Test existence of cachefiles
     
    598598    (argsfile,compressed1) = myopen(CD+FN+'_'+file_types[1],"rb",compression)
    599599    (admfile,compressed2) =  myopen(CD+FN+'_'+file_types[2],"rb",compression)
    600     test_OK('Presence of cache files')
     600    log_test_OK('Presence of cache files')
    601601    datafile.close()
    602602    argsfile.close()
    603603    admfile.close()
    604604  except:
    605     test_error('Expected cache files did not exist')
     605    log_test_error('Expected cache files did not exist')
    606606             
    607607  # Test 'test' function when cache is present
     
    613613    assert(T1 == T4)
    614614
    615     test_OK("Option 'test' when cache file present")
     615    log_test_OK("Option 'test' when cache file present")
    616616  except:
    617     test_error("Option 'test' when cache file present failed")     
     617    log_test_error("Option 'test' when cache file present failed")     
    618618
    619619  # Test that 'clear' works
     
    621621  #try:
    622622  #  cache(f,'clear',verbose=verbose)
    623   #  test_OK('Clearing of cache files')
     623  #  log_test_OK('Clearing of cache files')
    624624  #except:
    625   #  test_error('Clear does not work')
     625  #  log_test_error('Clear does not work')
    626626  try:
    627627    cache(f,(a,b,c,N), {'x':x, 'y':y}, verbose=verbose, clear=1)   
    628     test_OK('Clearing of cache files')
     628    log_test_OK('Clearing of cache files')
    629629  except:
    630     test_error('Clear does not work') 
     630    log_test_error('Clear does not work') 
    631631
    632632 
     
    637637    T4 = cache(f,(a,b,c,N), {'x':x, 'y':y}, verbose=verbose, test=1)
    638638    assert(T4 is None)
    639     test_OK("Option 'test' when cache absent")
     639    log_test_OK("Option 'test' when cache absent")
    640640  except:
    641     test_error("Option 'test' when cache absent failed")     
     641    log_test_error("Option 'test' when cache absent failed")     
    642642         
    643643  # Test dependencies
     
    649649                       
    650650  if T1 == T2:
    651     test_OK('Basic dependencies functionality')
     651    log_test_OK('Basic dependencies functionality')
    652652  else:
    653     test_error('Dependencies do not work')
     653    log_test_error('Dependencies do not work')
    654654
    655655  # Test basic wildcard dependency
     
    659659   
    660660  if T1 == T3:
    661     test_OK('Basic dependencies with wildcard functionality')
     661    log_test_OK('Basic dependencies with wildcard functionality')
    662662  else:
    663     test_error('Dependencies with wildcards do not work')
     663    log_test_error('Dependencies with wildcards do not work')
    664664
    665665
     
    675675 
    676676  if T3 is None:
    677     test_OK('Changed dependencies recognised')
     677    log_test_OK('Changed dependencies recognised')
    678678  else:
    679     test_error('Changed dependencies not recognised')   
     679    log_test_error('Changed dependencies not recognised')   
    680680 
    681681  # Test recomputation when dependencies have changed
     
    684684               dependencies=DepFN)                       
    685685  if T1 == T3:
    686     test_OK('Recomputed value with changed dependencies')
     686    log_test_OK('Recomputed value with changed dependencies')
    687687  else:
    688     test_error('Recomputed value with changed dependencies failed')
     688    log_test_error('Recomputed value with changed dependencies failed')
    689689
    690690  # Performance test (with statistics)
     
    705705  if T1 == T2:
    706706    if t1 > t2:
    707       test_OK('Performance test: relative time saved = %s pct' \
     707      log_test_OK('Performance test: relative time saved = %s pct' \
    708708              %str(round((t1-t2)*100/t1,2)))
    709709  else:       
    710     test_error('Basic caching failed for new problem')
     710    log_test_error('Basic caching failed for new problem')
    711711           
    712712  # Test presence of statistics file
     
    719719        fid = open(CD+FN,'r')
    720720        fid.close()
    721     test_OK('Statistics files present')
     721    log_test_OK('Statistics files present')
    722722  except:
    723     test_OK('Statistics files cannot be opened')         
     723    log_test_OK('Statistics files cannot be opened')         
    724724     
    725725  print_header_box('Show sample output of the caching function:')
     
    741741                   'time.strptime() which is unavailable in Windows')
    742742     
    743   test_OK('Caching self test completed')   
     743  log_test_OK('Caching self test completed')   
    744744     
    745745           
     
    767767                            # arguments.
    768768textwidth3 = 16             # Initial width of separation lines. Is modified.
    769 textwidth4 = 50             # Text width in test_OK()
     769textwidth4 = 50             # Text width in log_test_OK()
    770770statsfile  = '.cache_stat'  # Basefilename for cached statistics.
    771771                            # It will reside in the chosen cache directory.
     
    24952495# -----------------------------------------------------------------------------
    24962496
    2497 def test_OK(msg):
     2497def log_test_OK(msg):
    24982498  """Print OK msg if test is OK.
    24992499 
    25002500  USAGE
    2501     test_OK(message)
     2501    log_test_OK(message)
    25022502  """
    25032503
     
    25102510# -----------------------------------------------------------------------------
    25112511
    2512 def test_error(msg):
     2512def log_test_error(msg):
    25132513  """Print error if test fails.
    25142514 
    25152515  USAGE
    2516     test_error(message)
     2516    log_test_error(message)
    25172517  """
    25182518 
Note: See TracChangeset for help on using the changeset viewer.