2 import os,tempfile,shutil
7 class FileSystemBasedBehaviour(unittest.TestCase):
9 self.current_dir = os.getcwd()
10 self.tempdir = tempfile.mkdtemp()
11 os.chdir(self.tempdir)
13 os.chdir(self.current_dir)
14 #shutil.rmtree(self.tempdir,True)
16 def create_file(self,path):
17 inout.io.create_file(path).close()
19 def assertCreatedFile(self,path,error_message = None):
21 error_message = u"The file %s should have been created"%repr(path)
22 self.assertTrue(os.path.isfile(io.os_encode(path)),error_message)
24 class FileBasedBehaviour(FileSystemBasedBehaviour):
26 def file_content(self):
27 f=file(self.path(),'r')
32 def create_file(self,path=None):
35 super(FileBasedBehaviour,self).create_file(path)
37 def write(self,content,path=None):
40 inout.io.write(path,content)
43 __all__= ["FileBasedBehaviour","FileSystemBasedBehaviour"]