← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #693855]: NameError name 'ClassName' is not defined

 

Question #693855 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/693855

    Status: Open => Answered

RaiMan proposed the following answer:
This works for me:

--- new script in the IDE:
import unittest
import HTMLTestRunner

outDir = getBundlePath()
outHTML = os.path.join(outDir, "testOUT.html") 

class myTest(unittest.TestCase):
    def test1(self):
        pass

suite = unittest.TestLoader().loadTestsFromTestCase(myTest)
outfile = open(outHTML, "w")
testRunner = HTMLTestRunner.HTMLTestRunner(stream=outfile)
testRunner.run(suite)
outfile.close()

--- stored this as folder <somewhere>/testHTR
which gives
... <somewhere>/testHTR
... ... testHTR.py

--- running in the IDE creates
<somewhere>/testHTR/testOUT.html

--- running this from commandline:
java -jar sikulixide...jar -r <somewhere>/testHTR

works as expected.

I found, that one should not use "runner" as variable name (therefor I
used testRunner), since this leads to a problem (... isAborted() ...),.
Probably the name is already internally defined globally for something
else (I have to sort out).

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.