Exemple #1
0
def save_screenshot_dir():
    u"""
    将screenshot文件夹创建在工程目录
    """
    # 获取当前路径
    path1 = mainsys.mainsyspath()
    # curpath = os.getcwd()
    # path = sys.path[0]
    # if os.path.isdir(path):
    #     curpath = path
    # elif os.path.isfile(path):
    #     curpath = os.path.dirname(path)
    # # 分割路径为字符串
    # pathindex = curpath.split("\\")
    # # 查找路径的关键字
    # findindex = pathindex.index("test-lamppa-edu")
    # # 组合工程根路径
    # path = ''
    # for i in range(findindex):
    #     path = path + pathindex[i]+'\\'
    path1 += "\\screenshots\\" + str(date()) + "\\"
    if os.path.exists(path1):
        return path1
    else:
        os.makedirs(path1)
        return path1
Exemple #2
0
def info(string):
    filepath = inspect.stack()[1][1]
    lineno = inspect.stack()[1][2]
    filename = alldir.save_report_dir() + date.date() + '_testlog.log'
    f = open(filename, 'a')
    f.write("【INFO】" + string + "|" + date.datetimeall() + "|" + filepath +
            "|line:[" + str(lineno) + "]\n")
    f.close()
Exemple #3
0
# -*- coding: utf8 -*-
import unittest
import HTMLTestRunner
from src.test.public import alldir, date

filename = alldir.save_report_dir() + date.date()+'_testlog.log'
f = open(filename, 'a')
f.write("\n"+"*"*50+"开始执行"+"*"*50)
f.write("\n"+"开始打印本次运行全用例脚本的日志,开始时间:"+date.datetimeall()+"\n\n")
f.close()
 # 指明要自动查找的py文件所在文件夹路径

def createSuite():  # 产生测试套件
	base_dir = alldir.get_src_dir()
	testunit = unittest.TestSuite()
	# 使用discover找出用例文件夹下test_case的所有用例
	discover = unittest.defaultTestLoader.discover(base_dir+'src\\test\\test_case\\', pattern="test_*.py", top_level_dir=None)  # 测试模块的顶层目录,即测试用例不是放在多级目录下,设置为none
	for suite in discover:  # 使用for循环出suite,再循环出case
		for case in suite:
			testunit.addTests(case)
	print testunit
	return testunit
alltestnames = createSuite()
# 生成日志
filename = alldir.save_test_report_dir()+date.datetime()+'_test.html'
fp = file(filename, "wb")

runner = HTMLTestRunner.HTMLTestRunner(stream=fp,title=u"NG接口自动化测试报告",description=u"用例执行情况")
# 执行用例
print(u"开始运行脚本")
runner.run(alltestnames)
from src.test.public import base_info
from src.test.public import add_character
from src.test.public import create_phone_no
import sys
import os
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath)
cinema_code = base_info.cinema_code()
screen_code = base_info.screen_code()
net_user = base_info.net_user_name()
channel_id = base_info.net_channel_id()
channel_name = base_info.net_channel_name()
channel_order_no = add_character.add_code_by_need(
    3) + create_phone_no.createphoneno()
today = date.date()


# 查询影片信息
def film_info_xml():
    u"""查询影片信息"""
    msg = """ <?xml version="1.0" encoding="UTF-8"?>     
      <OnlineTicketingServiceQuery Version="1.0" Datetime="2018-08-03T14:31:22" Username="******" Password="******">
      <DQueryFilm EndDate="{EndDate}" Id="ID_DQueryFilm" StartDate="{StartDate}"></DQueryFilm>
      </OnlineTicketingServiceQuery>
      """
    msg = msg.format(Username=net_user, EndDate=today, StartDate=today)
    return msg


# 查询影厅座位信息