Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions autowsgr/ops/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- cook
- reward

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

| 模块 | 功能 | 状态 |
|------|------|------|
Expand All @@ -36,31 +36,31 @@
### startup 测试 ✅

```bash
python testing/ops/startup.py
python testing/ops/startup.py 127.0.0.1:16384
python tests/ops/startup.py
python tests/ops/startup.py 127.0.0.1:16384
```

### normal_fight 测试 ✅

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

### campaign 测试 ✅

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

### expedition 测试 ✅

```bash
python testing/ops/expedition.py
python testing/ops/expedition.py 127.0.0.1:16384
python tests/ops/expedition.py
python tests/ops/expedition.py 127.0.0.1:16384
```

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

```bash
python testing/ops/exercise.py --fleet 1
python testing/ops/exercise.py --fleet 1 --rival 3
python tests/ops/exercise.py --fleet 1
python tests/ops/exercise.py --fleet 1 --rival 3
```

### build 测试 ❌

```bash
python testing/ops/build.py
python testing/ops/build.py 127.0.0.1:16384
python tests/ops/build.py
python tests/ops/build.py 127.0.0.1:16384
```

### repair 测试 ❌

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

```bash
python testing/ops/repair.py
python testing/ops/repair.py 127.0.0.1:16384
python tests/ops/repair.py
python tests/ops/repair.py 127.0.0.1:16384
```

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

```bash
python testing/ops/destroy.py
python testing/ops/destroy.py 127.0.0.1:16384
python tests/ops/destroy.py
python tests/ops/destroy.py 127.0.0.1:16384
```

### cook 测试 ✅

```bash
python testing/ops/cook.py
python testing/ops/cook.py 127.0.0.1:16384 2
python tests/ops/cook.py
python tests/ops/cook.py 127.0.0.1:16384 2
```

### reward 测试 ✅

```bash
python testing/ops/reward.py
python testing/ops/reward.py 127.0.0.1:16384
python testing/ops/reward.py 127.0.0.1:16384 --auto
python tests/ops/reward.py
python tests/ops/reward.py 127.0.0.1:16384
python tests/ops/reward.py 127.0.0.1:16384 --auto
```
4 changes: 2 additions & 2 deletions docs/developer/test_pkg.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

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

它与 `testing/` 的分工:
它与 `tests/` 的分工:

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

`test_pkg/` 中的测试图片来自游戏实机截图,体积较大且可能涉及版权,因此不适合入库。
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dev = [
"pytest-cov",
"pytest-xdist",
"requests>=2.32.5",
"httpx>=0.28.0",
"beautifulsoup4",
]

Expand All @@ -50,7 +51,7 @@ path = "autowsgr/__init__.py"
ignore-words = "docs/spelling_wordlist.txt"

[tool.pytest.ini_options]
testpaths = ["testing"]
testpaths = ["tests/unit"]
addopts = ["--import-mode=importlib"]

[tool.ruff]
Expand Down Expand Up @@ -171,7 +172,7 @@ extend-safe-fixes = [
"__init__.py" = [
"F401", # unused-import
]
"testing/**" = [
"tests/**" = [
"T201", # print
]
"tools/**" = [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions testing/ops/build.py → tests/manual/ops/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

用法::

python testing/ops/build.py
python testing/ops/build.py 127.0.0.1:16384
python tests/manual/ops/build.py
python tests/manual/ops/build.py 127.0.0.1:16384

无页面前置要求 — collect_built_ships() 内部通过 goto_page() 自动导航。
"""
Expand All @@ -14,17 +14,17 @@
from pathlib import Path


sys.path.insert(0, str(Path(__file__).parent.parent.parent))
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent))

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

from testing.ops._framework import launch_for_test
from tests.manual.ops._framework import launch_for_test


_STEPS = [
Expand Down
14 changes: 7 additions & 7 deletions testing/ops/campaign.py → tests/manual/ops/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
用法::

# 自动检测设备,困难驱逐 x1
python testing/ops/campaign.py
python tests/manual/ops/campaign.py

# 指定设备 serial
python testing/ops/campaign.py 127.0.0.1:16384
python tests/manual/ops/campaign.py 127.0.0.1:16384

# 指定战役名和次数(serial 留空用自动检测)
python testing/ops/campaign.py "" 困难航母 3
python tests/manual/ops/campaign.py "" 困难航母 3

# 全参数
python testing/ops/campaign.py 127.0.0.1:16384 简单驱逐 2
python tests/manual/ops/campaign.py 127.0.0.1:16384 简单驱逐 2

可选参数::

Expand All @@ -36,8 +36,8 @@
# ── UTF-8 输出兼容(Windows 终端)──
try:
if hasattr(sys.stdout, 'reconfigure'):
sys.stdout.reconfigure(encoding='utf-8', errors='replace') # type: ignore # noqa: PGH003
sys.stderr.reconfigure(encoding='utf-8', errors='replace') # type: ignore # noqa: PGH003
sys.stdout.reconfigure(encoding='utf-8', errors='replace') # ty: ignore[call-non-callable]
sys.stderr.reconfigure(encoding='utf-8', errors='replace') # ty: ignore[call-non-callable]
except Exception:
try:
if isinstance(sys.stdout, io.TextIOWrapper):
Expand All @@ -54,7 +54,7 @@

from autowsgr.ops.campaign import CAMPAIGN_NAME_MAP, CampaignRunner
from autowsgr.types import ConditionFlag, Formation, RepairMode
from testing.ops._framework import launch_for_test
from tests.manual.ops._framework import launch_for_test


# ── 默认值 ──────────────────────────────────────────────────────────────────
Expand Down
12 changes: 6 additions & 6 deletions testing/ops/cook.py → tests/manual/ops/cook.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

用法::

python testing/ops/cook.py
python testing/ops/cook.py 127.0.0.1:16384
python tests/manual/ops/cook.py
python tests/manual/ops/cook.py 127.0.0.1:16384

无页面前置要求 — cook() 内部通过 goto_page() 自动导航到食堂。
"""
Expand All @@ -14,17 +14,17 @@
from pathlib import Path


sys.path.insert(0, str(Path(__file__).parent.parent.parent))
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent))

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

from testing.ops._framework import launch_for_test
from tests.manual.ops._framework import launch_for_test


_STEPS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

用法::

python testing/ops/decisive_battle.py
python testing/ops/decisive_battle.py 127.0.0.1:16384
python tests/manual/ops/decisive_battle.py
python tests/manual/ops/decisive_battle.py 127.0.0.1:16384

# 指定章节 (4-6) 和出击次数
python testing/ops/decisive_battle.py 127.0.0.1:16384 --chapter 6 --times 1
python tests/manual/ops/decisive_battle.py 127.0.0.1:16384 --chapter 6 --times 1

# 完整示例 (章节 6, 出击 2 次, 自定义舰船编组)
python testing/ops/decisive_battle.py 127.0.0.1:16384 \\
python tests/manual/ops/decisive_battle.py 127.0.0.1:16384 \\
--chapter 6 --times 2 \\
--level1 U-1206 U-96 射水鱼 大青花鱼 鹦鹉螺 鲃鱼 \\
--level2 甘比尔湾 平海 \\
Expand All @@ -25,20 +25,20 @@
from pathlib import Path


sys.path.insert(0, str(Path(__file__).parent.parent.parent))
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent))

# ── UTF-8 输出兼容 (Windows 终端) ──────────────────────────────────────────
try:
if hasattr(sys.stdout, 'reconfigure'):
sys.stdout.reconfigure(encoding='utf-8', errors='replace') # type: ignore # noqa: PGH003
sys.stderr.reconfigure(encoding='utf-8', errors='replace') # type: ignore # noqa: PGH003
sys.stdout.reconfigure(encoding='utf-8', errors='replace') # ty: ignore[call-non-callable]
sys.stderr.reconfigure(encoding='utf-8', errors='replace') # ty: ignore[call-non-callable]
except Exception: # noqa: S110
pass
from loguru import logger

from autowsgr.infra import DecisiveConfig
from autowsgr.ops.decisive import DecisiveController, DecisiveResult
from testing.ops._framework import launch_for_test
from tests.manual.ops._framework import launch_for_test


# ── 默认舰船配置 (第 6 章示例) ────────────────────────────────────────────
Expand Down
14 changes: 7 additions & 7 deletions testing/ops/destroy.py → tests/manual/ops/destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
用法::

# 1. 全量解装(不过滤舰种)
python testing/ops/destroy.py [serial]
python tests/manual/ops/destroy.py [serial]

# 2. 只解装驱逐 + 轻巡
python testing/ops/destroy.py [serial] --types DD CL
python tests/manual/ops/destroy.py [serial] --types DD CL

# 3. 不卸装备直接解装
python testing/ops/destroy.py [serial] --no-remove-equip
python tests/manual/ops/destroy.py [serial] --no-remove-equip

无页面前置要求 — destroy_ships() 内部通过 goto_page() 自动导航,
执行完毕后自动返回主页面。
Expand All @@ -22,18 +22,18 @@
from pathlib import Path


sys.path.insert(0, str(Path(__file__).parent.parent.parent))
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent))

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

from autowsgr.types import ShipType
from testing.ops._framework import launch_for_test
from tests.manual.ops._framework import launch_for_test


def _parse_args() -> argparse.Namespace:
Expand Down
16 changes: 8 additions & 8 deletions testing/ops/event_fight.py → tests/manual/ops/event_fight.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
用法::

# 自动检测设备,默认打 H3 x 1 次
python testing/ops/event_fight.py
python tests/manual/ops/event_fight.py

# 指定设备 serial
python testing/ops/event_fight.py 127.0.0.1:16384
python tests/manual/ops/event_fight.py 127.0.0.1:16384

# 指定 map_code 和次数
python testing/ops/event_fight.py "" H5 3
python tests/manual/ops/event_fight.py "" H5 3

# 全参数
python testing/ops/event_fight.py 127.0.0.1:16384 E2 2
python tests/manual/ops/event_fight.py 127.0.0.1:16384 E2 2

可选参数::

Expand All @@ -39,8 +39,8 @@
# ── UTF-8 输出兼容(Windows 终端)──
try:
if hasattr(sys.stdout, 'reconfigure'):
sys.stdout.reconfigure(encoding='utf-8', errors='replace') # type: ignore # noqa: PGH003
sys.stderr.reconfigure(encoding='utf-8', errors='replace') # type: ignore # noqa: PGH003
sys.stdout.reconfigure(encoding='utf-8', errors='replace') # ty: ignore[call-non-callable]
sys.stderr.reconfigure(encoding='utf-8', errors='replace') # ty: ignore[call-non-callable]
except Exception:
try:
if isinstance(sys.stdout, io.TextIOWrapper):
Expand All @@ -58,7 +58,7 @@
from autowsgr.combat import CombatMode, CombatPlan, NodeDecision, RuleEngine
from autowsgr.ops.event_fight import EventFightRunner
from autowsgr.types import ConditionFlag, FightCondition, Formation, RepairMode
from testing.ops._framework import launch_for_test
from tests.manual.ops._framework import launch_for_test


# ── 默认值 ──────────────────────────────────────────────────────────────────
Expand All @@ -67,7 +67,7 @@
_DEFAULT_FLEET_ID = 1
_DEFAULT_FORMATION = 'single_column'
_DEFAULT_PLAN_YAML = str(
Path(__file__).parent.parent.parent
Path(__file__).parent.parent.parent.parent
/ 'examples'
/ 'plans'
/ 'event'
Expand Down
Loading
Loading