← Back to team overview

sikuli-driver team mailing list archive

[Question #257256]: NameError (!! WHILE IMPORTING!!)

 

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

Hi,

Using Sikuli IDE 1.1.0-Beta1. 

Trying to execute tests using the HTMLTestRunner reporter and getting  the following error on line <<from POSTests import *>>  in main.sikuli

[error] script [ main ] stopped with error in line 9
[error] NameError ( !!WHILE IMPORTING!! name 'sys' is not defined )


# script named POSTests.sikuli
==============================
importPath = r"C:\SikuliScripts\UtilityFunctions.sikuli"
if not importPath in sys.path: sys.path.append(importPath)

from sikuli import *
import unittest
import UtilityFunctions

class LiqPOS(unittest.TestCase):
        
    def test_Sale1(self):
        print "SALE 01"

    def test_Sale2(self):
        print "SALE 02"

    def test_Sale3(self):
        print "Sale 03"


# script named main.sikuli
========================
from sikuli import *
import unittest

# import path for HTMLTestRunner
importPath = r"C:\SikuliScripts\HTMLTestRunner.sikuli"
if not importPath in sys.path: sys.path.append(importPath)

import HTMLTestRunner

from POSTests import *

# path to report folder
dir = "C:\\SikuliReports\\LiquorPOS\\"
import os
fp = file(os.path.join(dir, "Rep.html"), "wb")

suite = unittest.TestLoader().loadTestsFromTestCase(LiqPOS)
runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title='POS', description='Simple POS Sale')
runner.run(suite)
fp.close()


If i move the code from main.sikuli to the POSTests.sikuli, it works fine. It must be to do with the way I'm importing, both scripts are in the same directory. Any help is appreciated.

Thanks.

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