File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ [pytest]
2+ markers =
3+ pyabacus: tests that require local pyabacus integration (disabled by default via ENABLE_PYABACUS_TESTS)
Original file line number Diff line number Diff line change 5050
5151- ` pyscf ` 、` abacus ` 、` pyabacus ` 为可选依赖。
5252- 若环境未安装,对应测试会自动 ` skip ` ,不影响其余测试回归。
53+ - ` pyabacus ` 相关测试在仓库默认策略下也会被禁用;仅在显式设置 ` ENABLE_PYABACUS_TESTS=1 ` 时启用。
Original file line number Diff line number Diff line change 11"""
22全局测试配置:
33- 固定随机种子,降低非确定性波动;
4+ - 默认关闭 `pyabacus` 相关测试(可通过环境变量显式开启);
45- 作为后续共享 fixture 的统一入口。
56"""
67
8+ import os
79import random
810
911import numpy as np
@@ -21,3 +23,13 @@ def _fixed_seed():
2123 torch .manual_seed (20260313 )
2224 except Exception :
2325 pass
26+
27+
28+ def pytest_collection_modifyitems (config , items ):
29+ """默认跳过 pyabacus 相关测试,除非显式开启。"""
30+ if os .getenv ("ENABLE_PYABACUS_TESTS" , "0" ) == "1" :
31+ return
32+ skip_marker = pytest .mark .skip (reason = "pyabacus tests are disabled by default in this repository" )
33+ for item in items :
34+ if item .get_closest_marker ("pyabacus" ):
35+ item .add_marker (skip_marker )
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ def test_migrated_integral_scf_placeholder_sample():
7575 assert "model_file" in cfg
7676
7777
78+ @pytest .mark .pyabacus
7879def test_migrated_integral_train_sample_if_pyabacus (tmp_path ):
7980 """
8081 依赖:`pyabacus`(可选)、`deepks.model.train.main` 与迁移样例 `train_input.yaml`。
@@ -95,6 +96,7 @@ def test_migrated_integral_train_sample_if_pyabacus(tmp_path):
9596 assert lines [- 1 ].split ()[- 1 ] == "3.0845e-04"
9697
9798
99+ @pytest .mark .pyabacus
98100def test_migrated_integral_test_sample_if_pyabacus (tmp_path ):
99101 """
100102 依赖:`pyabacus`(可选)、`deepks.model.test.main` 与迁移样例 `test_input.yaml`。
Original file line number Diff line number Diff line change 1111import torch .nn as nn
1212
1313pytest .importorskip ("pyabacus" )
14+ pytestmark = pytest .mark .pyabacus
1415
1516from deepks .model .evaluator import Evaluator
1617
You can’t perform that action at this time.
0 commit comments