Skip to content
📔 阅读量:

配置模块 ​

配置模块路径 ​

shell
my_autotest
├─ case
│   ├─ assert_res
│   │   └─ README.md
│   ├─ base_case.py
│   ├─ test_mycase_001.py
│   └─ test_mycase_002.py
├─ method
│   ├─ image_res
│   │   └─ README.md
│   ├─ static_res
│   │   └─ README.md
│   ├─ assert_method.py
│   ├─ base_method.py
│   ├─ my_autotest_method.py
│   └─ ui.ini
├─ .gitignore
├─ README.md
├─ config.py  <--工程配置
├─ conftest.py
├─ mycase.csv
├─ pytest.ini
├─ requirements.txt
└─ ruff.toml

config.py

python
import pathlib


class _Config:

    ROOTDIR = pathlib.Path(__file__).parent
    ASSERT_RES = ROOTDIR / "case/assert_res"
    IMAGE_RES = ROOTDIR / "method/image_res"
    STATIC_RES = ROOTDIR / "method/static_res"


config = _Config()

可以根据需要在里面添加配置。

代码中调用 ​

python
from config import config

config.ROOTDIR

调用YouQu3的配置 ​

python
from youqu3 import setting

setting.IS_X11