Example #1
0
 def loggerAPI(self, level, msg):
     try:
         logger = logging.getLogger("API_AUTO")
         logger.setLevel(logging.DEBUG)
         streamHandler = logging.StreamHandler()
         streamHandler.setLevel(logging.DEBUG)
         fileHandler = logging.FileHandler(filename=pathUtils.pathApi(
             file_paths=["learn", "log", "{0}.log".format(datetime.datetime.now().strftime('%Y%m%d'))]),encoding="UTF-8")
         formatter = logging.Formatter(
             fmt='Time:%(asctime)s-level:%(levelname)s-%(filename)s-[line:%(lineno)d]-%(name)s-日志信息 : %(message)s')
         streamHandler.setFormatter(formatter)
         fileHandler.setFormatter(formatter)
         logger.addHandler(streamHandler)
         logger.addHandler(fileHandler)
         if level.upper() == "DEBUG":
             logger.debug(msg)
         elif level.upper() == "INFO":
             logger.info(msg)
         elif level.upper() == "WARNING":
             logger.warning(msg)
         elif level.upper() == "ERROR":
             logger.error(msg)
         elif level.upper() == "CRITICAL":
             logger.critical(msg)
         else:
             logger.debug("输入错误的level,msg:{0}".format(msg))
     except Exception as e:
         self.error(msg=e)
         raise e
     finally:
         logger.removeHandler(streamHandler)
         logger.removeHandler(fileHandler)
Example #2
0
class getData:
    Authorization = None

    admin_username = pd.read_excel(io=pathUtils.pathApi(
        file_paths=["test_data", "TestData_Parameterist.xlsx"]),
                                   sheet_name="parameters",
                                   index_col="Key").loc['admin_username',
                                                        'Value']
    admin_password = pd.read_excel(io=pathUtils.pathApi(
        file_paths=["test_data", "TestData_Parameterist.xlsx"]),
                                   sheet_name="parameters",
                                   index_col="Key").loc['admin_password',
                                                        'Value']

    real_name = pd.read_excel(io=pathUtils.pathApi(
        file_paths=["test_data", "TestData_Parameterist.xlsx"]),
                              sheet_name="parameters",
                              index_col="Key").loc['real_name', 'Value']
    email = pd.read_excel(io=pathUtils.pathApi(
        file_paths=["test_data", "TestData_Parameterist.xlsx"]),
                          sheet_name="parameters",
                          index_col="Key").loc["email", "Value"]
    mobile = pd.read_excel(io=pathUtils.pathApi(
        file_paths=["test_data", "TestData_Parameterist.xlsx"]),
                           sheet_name="parameters",
                           index_col="Key").loc["mobile", "Value"]
    password = pd.read_excel(io=pathUtils.pathApi(
        file_paths=["test_data", "TestData_Parameterist.xlsx"]),
                             sheet_name="parameters",
                             index_col="Key").loc["password", "Value"]
    companyId = pd.read_excel(io=pathUtils.pathApi(
        file_paths=["test_data", "TestData_Parameterist.xlsx"]),
                              sheet_name="parameters",
                              index_col="Key").loc["companyId", "Value"]
    account = pd.read_excel(io=pathUtils.pathApi(
        file_paths=["test_data", "TestData_Parameterist.xlsx"]),
                            sheet_name="parameters",
                            index_col="Key").loc["account", "Value"]

    @staticmethod
    def getData(sheet_name, key):
        df = pd.read_excel(
            io=r"D:\PythonWorkspace\Demo1\API_AUTO\test_data\TestData.xlsx",
            sheet_name=sheet_name)
        return df
Example #3
0
# @Author: Chris Paul
# @Time: 2021/02/18 22:52
# @File: run.py

import HTMLTestReportCN
import unittest
from API_AUTO.test_case.testCase_requestAPI import testCase_RequestAPI
from API_AUTO.utils.pathUtil import pathUtils

suite = unittest.TestSuite()
loader = unittest.TestLoader()
suite.addTest(loader.loadTestsFromTestCase(testCase_RequestAPI))
with open(file=pathUtils.pathApi(file_paths=["test_report","test_report_requestAPI.html"]),mode="wb") as file:
    run = HTMLTestReportCN.HTMLTestRunner(stream=file,title="requestAPI接口测试",description="requestAPI接口测试",tester="CP3").run(suite)

Example #4
0
# @Author: Chris Paul
# @Time: 2021/02/24 23:06
# @File: Demo1_numpy.py.py

import pandas as pd
from API_AUTO.utils.pathUtil import pathUtils

# 创建一个Excel文件
# df = pd.DataFrame({'ID':[1,2,3],'Name':["Paul","Chris","Geo"]})
# df = df.set_index(keys="ID")
# print(df)
# df.to_excel(excel_writer="text.xlsx")
# print("Done!")

# 读取一个Excel
df = pd.read_excel(
    io=pathUtils.pathApi(file_paths=["test_data", "TestData.xlsx"]),
    index_col="caseID").ix[0, 0]
print(df)
Example #5
0
# author:ChriPaul
# file:Demo1_pandas.py.py
# time:2021/02/23

import pandas as pd
from API_AUTO.utils.pathUtil import pathUtils

df = pd.read_excel(io=(pathUtils.pathApi(file_paths=["test_data","TestData_Parameterist.xlsx"])),sheet_name="TestData")
print(df["名字"])

df['等级'][df['名字']=='圣甲狂战'] +=1
print(df['等级'][df['名字']=='圣甲狂战'])