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

Source Code for Module qm.test.classes.temporary

 1  ######################################################################## 
 2  # 
 3  # File:   temporary.py 
 4  # Author: Alex Samuel 
 5  # Date:   2001-04-06 
 6  # 
 7  # Contents: 
 8  #   Resource classes to manage temporary files and directories. 
 9  # 
10  # Copyright (c) 2001, 2002, 2003 by CodeSourcery, LLC.  All rights reserved.  
11  # 
12  # For license terms see the file COPYING. 
13  # 
14  ######################################################################## 
15   
16  ######################################################################## 
17  # imports 
18  ######################################################################## 
19   
20  import os 
21  import qm.common 
22  import qm.fields 
23  from   qm.test.result import * 
24  from   qm.test.test import * 
25  from   qm.test.resource import * 
26  import qm.temporary_directory 
27   
28  ######################################################################## 
29  # classes 
30  ######################################################################## 
31   
32 -class TempDirectoryResource(Resource):
33 """Resource class to manage a temporary directory. 34 35 An instance of this resource creates a temporary directory during 36 setup, and deletes it during cleanup. The full path to the 37 directory is available to tests via a context property.""" 38 39 arguments = [ 40 qm.fields.TextField( 41 name="dir_path_property", 42 title="Directory Path Property Name", 43 description="The name of the context property which is " 44 "set to the path to the temporary directory.", 45 default_value="temp_dir_path" 46 ), 47 48 qm.fields.IntegerField( 49 name="delete_recursively", 50 title="Delete Directory Recursively", 51 description="""This field is obsolete All temporary 52 directories are removed recursively.""", 53 default_value=1, 54 ), 55 ] 56 57
58 - def SetUp(self, context, result):
59 60 # Generate a temporary file name. 61 self.__dir = qm.temporary_directory.TemporaryDirectory() 62 context[self.dir_path_property] = self.__dir.GetPath()
63 64
65 - def CleanUp(self, result):
66 67 del self.__dir
68 69 70 ######################################################################## 71 # Local Variables: 72 # mode: python 73 # indent-tabs-mode: nil 74 # fill-column: 72 75 # End: 76