• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright (C) 2025 Huawei Device Co., Ltd.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# 运行环境: python 3.10+, pytest, pytest-repeat, pytest-testreport allure-pytest
16# pytest-xdist, pytest-ordering, pytest-rerunfailures, setuptools, Jinja2, requests
17# 准备文件:package.zip
18# 执行方式:python main.py
19
20import subprocess
21import pytest
22import os
23import time
24import prepare
25from testModule.utils import GP, check_library_installation, pytest_run, load_gp
26
27
28def get_version_file():
29    version_file_path = os.path.join(os.getcwd(), "resource", "version")
30    if os.path.exists(version_file_path):
31        with open(version_file_path, "r", encoding="UTF-8") as version_file:
32            version = version_file.read().strip()
33            return version
34    else:
35        return "unknown"
36
37
38def is_gen_conf():
39    config_file_path = os.path.join(os.getcwd(), ".hdctester.conf")
40    return os.path.exists(config_file_path)
41
42
43def main():
44    if check_library_installation("pytest"):
45        subprocess.check_call(["pip", "install", "-r", "requirements.txt"])
46        if check_library_installation("pytest"):
47            return
48    start_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
49    if get_version_file() == "unknown":
50        prepare.prepare()
51    if not is_gen_conf():
52        GP.init()
53    pytest_run()
54
55
56if __name__ == '__main__':
57    main()