Example #1
0
def _init_rmLog():
    filePath = getReg.getRegVal("workSpace")    #获取workspace
    filePath = filePath+'\\runtime\\'

    despath = getReg.getRegVal("workSpace")
    despath = despath+"\\temp\\"
    
    fileName=time.strftime('%Y_%m_%d',time.localtime((time.time()))) +'.log'   
    fileRes=filePath+fileName
    if os.path.exists(fileRes):             #删除执行QuikLab时产生的日志
        os.remove(fileRes)
    if os.path.exists(despath):             #删除临时安装文件下载文件夹
        shutil.rmtree(despath)

#检查用户名和工程名是否存在
    tpList=case_wrapper.readIniConfig('QuikLab3.0')
    ck=check()
    if ck.ckUname(tpList[1]) == 1 and ck.ckProName(ck.getProName(tpList[3])) == 0:  #检查用户名和工程名返回值
        pass
    else:
        exit()
    print "Init finish!"
Example #2
0
def compareRes():
    workSpace=getReg.getRegVal("workSpace")                 #从注册表获取workspace地址
    filePath='%s\\runtime\\'%workSpace
    print filePath
    fileName=time.strftime('%Y_%m_%d',time.localtime((time.time()))) +'.log'    #日志命名为"当前时间"+".log"
    logFile=filePath+fileName
    print logFile
#     case.isNotIn('未通过',logFile, True,'测试成功')
#     case.isNotIn('失败',logFile,'测试成功')

    despath=dirLocation.searchDir('report')

#     os.chdir(despath)
#     despath=os.getcwd()

    print despath,"..."
    os.system('copy %s %s'%(logFile,despath))         #将测试结果拷贝到report目录下
    isNotIn('未通过',logFile,'测试成功')                   #测试结果若匹配不到"未通过",则表明测试通过
Example #3
0
def compareRes():
#     username = getpass.getuser()
#     path=case.get_workspace()
    path=getReg.getRegVal('workspace')
    print path
    filePath=path+'\\runtime\\'
#     os.chdir(filePath)
#     print filePath
    fileName=time.strftime('%Y_%m_%d',time.localtime((time.time()))) +'.log'
    logFile=filePath+fileName
#     print logFile
#     case.isNotIn('未通过',logFile, True,'测试成功')
    path = sys.path[0] + r"\report"
    if not os.path.exists(path):
        path = os.path.abspath("..") + r"\report"

    if not os.path.exists(path):
        path = os.path.abspath("..\..") + r"\report"
    os.system('copy %s %s'%(logFile,path))
    case.isNotIn('失败',logFile,'测试成功')
    case.isNotIn('未通过',logFile,'测试成功')
Example #4
0
#! /usr/bin/env python
#coding=GB18030
import getpass
import logging
import os
import unittest

from casebase import getReg
import casebase.case_wrapper as case


configList = case.readIniConfig('QuikLab3.0')
pyfilename = os.path.basename(__file__)
softSetupDir = getReg.getRegVal('applicationPath')
appPath = softSetupDir + '\\MainApp.exe'

class Test(unittest.TestCase):
    def setUp(self):
        pass

    def testConfDataBase(self):
        case.confDataBase(softSetupDir,appPath,configList[4])
        username = getpass.getuser()
        xmlList = case.readXml('C:\Users\%s\QuiKLab3\config.xml'%username, 'hostname')
        case.isNotIN('192.168.1.227', xmlList, pyfilename,"192.168.1.227不在xml文件中")
            
    def tearDown(self):
        pass
#         case.closeLogin(u'登录--试验自动测试管理系统', u"退出")        
        
        
@author: KLJS044
'''
import ctypes
import json
import os
import time
import unittest
# import compareVal
import casebase.getReg as regInfo
import data
import readConfig


a='\x00' #C语言中的空格
configList = readConfig.readIniConfig('QuikLab3.0')
regInfo = regInfo.getRegVal('applicationPath')
# os.chdir(regInfo)
lib = ctypes.cdll.LoadLibrary(r"QuiKLabAPI.dll")


class Test(unittest.TestCase):
    def setUp(self):
        assert lib.initQuiKLabPlatform() == 0,'初始化失败!\n'                 
        time.sleep(5)
        lib.loadProject(configList[4])


    def tearDown(self):
        assert lib.releaseQuiKLabPlatform() == 0,'工程释放失败!\n'

import unittest
import ctypes
import json
import os
import time
import sys


import casebase.getReg as regInfo
import data
import readConfig


a='\x00' #C语言中的空格
configList = readConfig.readIniConfig('QuikLab3.0')
installSpace=regInfo.getRegVal("applicationPath")
workSpace=regInfo.getRegVal("workSpace")
# os.chdir(installSpace)
lib = ctypes.cdll.LoadLibrary(r"QuiKLabAPI.dll")
R=data.check()
sqlProName=R.getProName()    #数据库获取工程名称
class Test(unittest.TestCase):


    def setUp(self):
        lib.initQuiKLabPlatform()


    def tearDown(self):
        lib.releaseQuiKLabPlatform()
Example #7
0
                    filename='test.log',
                    filemode='w'
                    )
class Logger(object):
    def __init__(self,fileN='Default.log'):
        self.terminal=sys.stdout
        self.log=open(fileN,'w')
    def write(self,message):
        self.terminal.write(message)
        self.log.write(message)
    def flush(self):
        pass
sys.stdout=Logger('1.txt')
a='\x00' #C语言中的空格
configList=readConfig.readIniConfig('QuikLab3.0')
dir=getReg.getRegVal('applicationPath')
os.chdir(dir)
lib = ctypes.cdll.LoadLibrary("QuiKLabAPI.dll")
val=lib.initQuiKLabPlatform()
if val==0:
    print "初始化QuiKLab平台类成功\n"    
time.sleep(5)
print("获取下位机数量:\n"),lib.getTargetCount()
print("根据索引获取下位机IP:")
IP="iP"*64
lib.getTargetIP(0,IP,len(IP))
print IP.strip(a)
    
print"根据索引获取下位机状态:\n",lib.getTargetState(0)
    
print"设置使用中的下位机IP:\n",lib.useTargetIp("192.168.1.5") 
Example #8
0
 def test1_Login(self):
     softSetupDir = getReg.getRegVal('applicationPath')      #根据注册表信息获取QuikLab安装目录
     appPath = softSetupDir + '\\MainApp.exe'
     case.login(softSetupDir,appPath,configList[1],configList[2])    #启动QuikLab并进行登录测试