Package nMOLDYN :: Package Tests :: Module BuildTestCases
[hide private]
[frames] | no frames]

Source Code for Module nMOLDYN.Tests.BuildTestCases

 1  # This python script creates automatically the test cases for a given analysis. 
 2  # It needs: 
 3  #   -the file 'testContents.txt' located in REFERENCES\ANALYSIS directory where 
 4  # ANALYSIS is the name of the analysis for which the test cases should be built (i.e. MSD, VACF ...). 
 5   
 6  import sys 
 7  import os 
 8  from MMTK import Units 
 9  nmoldyn_package_path = '/home/cs/pellegrini/nMOLDYN/development' 
10   
11  sys.path.insert(0, nmoldyn_package_path) 
12   
13  analysis = sys.argv[1] 
14   
15  testContents = open(os.path.join(analysis,'TestsContents.py'),'r') 
16  exec testContents 
17  testContents.close() 
18   
19  for t in range(len(test)): 
20      tInd = str(t + 1) 
21      referenceTestFile = open(os.path.join(analysis, analysis + tInd +'_Reference.inp'),'w') 
22      referenceTestFile.write('from MMTK import *\n') 
23      for key, val in template['REF'].items() + test[t]['REF'].items(): 
24          if isinstance(val, str): 
25              referenceTestFile.write('%s = %s\n' % (key, repr(val))) 
26          else: 
27              referenceTestFile.write('%s = %s\n' % (key, val)) 
28      referenceTestFile.close() 
29