← Back to team overview

sikuli-driver team mailing list archive

[Question #246394]: Write to same file from different modules

 

New question #246394 on Sikuli:
https://answers.launchpad.net/sikuli/+question/246394

I have a test suite which is a collection of tests running from different modules. At different points in different tests I want to verify that something exists and write into a separate txt file that it does. But I can only get the first module called to write to the file, the second module does not. I guess one dirty solution is to have separate files for each module.
Another strange thing is that the following code runs one time, but when I run it a second time i get the error:
[error] script [ testsuite] stopped with error in line 2
[error] ValueError ( I/O operation on closed file )

Here is a condensed version of what i´ve done so far:


(Module: testsuite.sikuli)
Import Method1
Method1.tst1()


(Module:Method1.sikuli)
import Method2
from sikuli import *
logfile = file("C:\\Users\\caan\\Documents\\SikuliTests\\TwoImports\\output.txt","w")
def tst1():
    logfile.write("This is tst1" + "\n")
    logfile.close
    Method2.tst2()


(Module :Method2.sikuli)
from sikuli import *
logfile = file("C:\\Users\\caan\\Documents\\SikuliTests\\TwoImports\\output.txt","w")
def tst2():
    logfile.write("this is tst2" + "\n")
    logfile.close


-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.