Package qm :: Package test :: Package classes :: Module dir_run_database
[hide private]
[frames] | no frames]

Source Code for Module qm.test.classes.dir_run_database

 1  ######################################################################## 
 2  # 
 3  # File:   dir_run_database.py 
 4  # Author: Mark Mitchell 
 5  # Date:   2005-08-08 
 6  # 
 7  # Contents: 
 8  #   QMTest DirRunDatabase class. 
 9  # 
10  # Copyright (c) 2005 by CodeSourcery, LLC.  All rights reserved.  
11  # 
12  # For license terms see the file COPYING. 
13  # 
14  ######################################################################## 
15   
16  ######################################################################## 
17  # Imports 
18  ######################################################################## 
19   
20  from glob import glob 
21  import os.path 
22  from qm.test import base 
23  from qm.test.reader_test_run import ReaderTestRun 
24  from qm.test.run_database import RunDatabase 
25   
26  ######################################################################## 
27  # Classes 
28  ######################################################################## 
29   
30 -class DirRunDatabase(RunDatabase):
31 """A 'DirRunDatabase' reads test runs from a directory. 32 33 A 'DirRunDatabase' is associated with a given directory. The 34 database consists of all '.qmr' files in the directory. Each 35 '.qmr' file is treated as a result file.""" 36
37 - def __init__(self, directory, database):
38 """Create a new 'DirRunDatabase'. 39 40 'directory' -- The path to the directory containing the 41 results files. 42 43 'database' -- The test 'Database' to which the results files 44 correspond.""" 45 46 self.__runs = [] 47 # Read through all the .qmr files. 48 for f in glob(os.path.join(directory, "*.qmr")): 49 try: 50 # Create the ResultReader corresponding to f. 51 reader = base.load_results(f, database) 52 run = ReaderTestRun(reader) 53 except: 54 # If anything goes wrong reading the file, just skip 55 # it. 56 continue 57 # Add this run to the list. 58 self.__runs.append(run)
59 60
61 - def GetAllRuns(self):
62 63 return self.__runs
64