Skip to content

Commit 244c77f

Browse files
committed
test: separate manual e2e tests and add one-to-one unit test structure
1 parent 176eec9 commit 244c77f

213 files changed

Lines changed: 12831 additions & 214 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

autowsgr/ops/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- cook
1616
- reward
1717

18-
每个模块只有少量功能,全部做 e2e 测试即可。测试脚本统一放在 `testing/ops/` 下。
18+
每个模块只有少量功能,全部做 e2e 测试即可。测试脚本统一放在 `tests/manual/ops/` 下。
1919

2020
| 模块 | 功能 | 状态 |
2121
|------|------|------|
@@ -36,31 +36,31 @@
3636
### startup 测试 ✅
3737

3838
```bash
39-
python testing/ops/startup.py
40-
python testing/ops/startup.py 127.0.0.1:16384
39+
python tests/ops/startup.py
40+
python tests/ops/startup.py 127.0.0.1:16384
4141
```
4242

4343
### normal_fight 测试 ✅
4444

4545
```bash
46-
python testing/ops/normal_fight.py
47-
python testing/ops/normal_fight.py 127.0.0.1:16384 3 # 指定设备和次数
48-
python testing/ops/normal_fight.py --plan examples/plans/normal_fight/7-46SS-all.yaml
46+
python tests/ops/normal_fight.py
47+
python tests/ops/normal_fight.py 127.0.0.1:16384 3 # 指定设备和次数
48+
python tests/ops/normal_fight.py --plan examples/plans/normal_fight/7-46SS-all.yaml
4949
```
5050

5151
### campaign 测试 ✅
5252

5353
```bash
54-
python testing/ops/campaign.py # 困难驱逐 x1
55-
python testing/ops/campaign.py 127.0.0.1:16384 困难航母 3 # 指定战役和次数
56-
python testing/ops/campaign.py "" 简单驱逐 2
54+
python tests/ops/campaign.py # 困难驱逐 x1
55+
python tests/ops/campaign.py 127.0.0.1:16384 困难航母 3 # 指定战役和次数
56+
python tests/ops/campaign.py "" 简单驱逐 2
5757
```
5858

5959
### expedition 测试 ✅
6060

6161
```bash
62-
python testing/ops/expedition.py
63-
python testing/ops/expedition.py 127.0.0.1:16384
62+
python tests/ops/expedition.py
63+
python tests/ops/expedition.py 127.0.0.1:16384
6464
```
6565

6666
### decisive 测试 ❌
@@ -70,24 +70,24 @@ python testing/ops/expedition.py 127.0.0.1:16384
7070
### exercise 测试 ✅
7171

7272
```bash
73-
python testing/ops/exercise.py --fleet 1
74-
python testing/ops/exercise.py --fleet 1 --rival 3
73+
python tests/ops/exercise.py --fleet 1
74+
python tests/ops/exercise.py --fleet 1 --rival 3
7575
```
7676

7777
### build 测试 ❌
7878

7979
```bash
80-
python testing/ops/build.py
81-
python testing/ops/build.py 127.0.0.1:16384
80+
python tests/ops/build.py
81+
python tests/ops/build.py 127.0.0.1:16384
8282
```
8383

8484
### repair 测试 ❌
8585

8686
#### 修复第一艘舰船 ✅
8787

8888
```bash
89-
python testing/ops/repair.py
90-
python testing/ops/repair.py 127.0.0.1:16384
89+
python tests/ops/repair.py
90+
python tests/ops/repair.py 127.0.0.1:16384
9191
```
9292

9393
#### 按照名称修复舰船 ❌
@@ -97,21 +97,21 @@ python testing/ops/repair.py 127.0.0.1:16384
9797
### destroy 测试 ✅
9898

9999
```bash
100-
python testing/ops/destroy.py
101-
python testing/ops/destroy.py 127.0.0.1:16384
100+
python tests/ops/destroy.py
101+
python tests/ops/destroy.py 127.0.0.1:16384
102102
```
103103

104104
### cook 测试 ✅
105105

106106
```bash
107-
python testing/ops/cook.py
108-
python testing/ops/cook.py 127.0.0.1:16384 2
107+
python tests/ops/cook.py
108+
python tests/ops/cook.py 127.0.0.1:16384 2
109109
```
110110

111111
### reward 测试 ✅
112112

113113
```bash
114-
python testing/ops/reward.py
115-
python testing/ops/reward.py 127.0.0.1:16384
116-
python testing/ops/reward.py 127.0.0.1:16384 --auto
114+
python tests/ops/reward.py
115+
python tests/ops/reward.py 127.0.0.1:16384
116+
python tests/ops/reward.py 127.0.0.1:16384 --auto
117117
```

docs/developer/test_pkg.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
`test_pkg/` 是本地私有的视觉/OCR 回归测试集合,**不纳入版本控制**(已在 `.gitignore` 中排除),也不随 PyPI 包发布。
66

7-
它与 `testing/` 的分工:
7+
它与 `tests/` 的分工:
88

99
| 目录 | 作用 | 版本控制 | 框架 |
1010
|------|------|----------|------|
11-
| `testing/` | 单元测试、集成测试 || pytest |
11+
| `tests/` | 单元测试、集成测试 || pytest |
1212
| `test_pkg/` | 视觉/OCR 回归测试(含截图) | 否(本地私有) | 独立脚本 |
1313

1414
`test_pkg/` 中的测试图片来自游戏实机截图,体积较大且可能涉及版权,因此不适合入库。

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dev = [
3737
"pytest-cov",
3838
"pytest-xdist",
3939
"requests>=2.32.5",
40+
"httpx>=0.28.0",
4041
"beautifulsoup4",
4142
]
4243

@@ -51,7 +52,7 @@ path = "autowsgr/__init__.py"
5152
ignore-words = "docs/spelling_wordlist.txt"
5253

5354
[tool.pytest.ini_options]
54-
testpaths = ["testing"]
55+
testpaths = ["tests/unit"]
5556
addopts = ["--import-mode=importlib"]
5657

5758
[tool.ruff]
@@ -172,7 +173,7 @@ extend-safe-fixes = [
172173
"__init__.py" = [
173174
"F401", # unused-import
174175
]
175-
"testing/**" = [
176+
"tests/**" = [
176177
"T201", # print
177178
]
178179
"tools/**" = [
File renamed without changes.
File renamed without changes.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
用法::
44
5-
python testing/ops/build.py
6-
python testing/ops/build.py 127.0.0.1:16384
5+
python tests/manual/ops/build.py
6+
python tests/manual/ops/build.py 127.0.0.1:16384
77
88
无页面前置要求 — collect_built_ships() 内部通过 goto_page() 自动导航。
99
"""
@@ -14,17 +14,17 @@
1414
from pathlib import Path
1515

1616

17-
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
17+
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent))
1818

1919
try:
2020
if hasattr(sys.stdout, 'reconfigure'):
21-
sys.stdout.reconfigure(encoding='utf-8', errors='replace') # type: ignore # noqa: PGH003
22-
sys.stderr.reconfigure(encoding='utf-8', errors='replace') # type: ignore # noqa: PGH003
21+
sys.stdout.reconfigure(encoding='utf-8', errors='replace') # ty: ignore[call-non-callable]
22+
sys.stderr.reconfigure(encoding='utf-8', errors='replace') # ty: ignore[call-non-callable]
2323
except Exception: # noqa: S110
2424
pass
2525
from loguru import logger
2626

27-
from testing.ops._framework import launch_for_test
27+
from tests.manual.ops._framework import launch_for_test
2828

2929

3030
_STEPS = [
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
用法::
66
77
# 自动检测设备,困难驱逐 x1
8-
python testing/ops/campaign.py
8+
python tests/manual/ops/campaign.py
99
1010
# 指定设备 serial
11-
python testing/ops/campaign.py 127.0.0.1:16384
11+
python tests/manual/ops/campaign.py 127.0.0.1:16384
1212
1313
# 指定战役名和次数(serial 留空用自动检测)
14-
python testing/ops/campaign.py "" 困难航母 3
14+
python tests/manual/ops/campaign.py "" 困难航母 3
1515
1616
# 全参数
17-
python testing/ops/campaign.py 127.0.0.1:16384 简单驱逐 2
17+
python tests/manual/ops/campaign.py 127.0.0.1:16384 简单驱逐 2
1818
1919
可选参数::
2020
@@ -36,8 +36,8 @@
3636
# ── UTF-8 输出兼容(Windows 终端)──
3737
try:
3838
if hasattr(sys.stdout, 'reconfigure'):
39-
sys.stdout.reconfigure(encoding='utf-8', errors='replace') # type: ignore # noqa: PGH003
40-
sys.stderr.reconfigure(encoding='utf-8', errors='replace') # type: ignore # noqa: PGH003
39+
sys.stdout.reconfigure(encoding='utf-8', errors='replace') # ty: ignore[call-non-callable]
40+
sys.stderr.reconfigure(encoding='utf-8', errors='replace') # ty: ignore[call-non-callable]
4141
except Exception:
4242
try:
4343
if isinstance(sys.stdout, io.TextIOWrapper):
@@ -54,7 +54,7 @@
5454

5555
from autowsgr.ops.campaign import CAMPAIGN_NAME_MAP, CampaignRunner
5656
from autowsgr.types import ConditionFlag, Formation, RepairMode
57-
from testing.ops._framework import launch_for_test
57+
from tests.manual.ops._framework import launch_for_test
5858

5959

6060
# ── 默认值 ──────────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)