From cbc653ffd0ea9abf4360623dc7a7651e1a49cc61 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Sat, 25 Oct 2025 00:30:48 +0800 Subject: feat: Implement plugin system with combat tracker and dice analyzer - Added `plugin_system_demo.py` to demonstrate basic plugin usage, processing, and analysis. - Created `CombatTrackerPlugin` for tracking combat statistics including damage and healing. - Developed `DiceAnalyzerPlugin` for analyzing dice rolls and calculating success rates. - Introduced `renderer_demo.py` for rendering output in HTML, Markdown, and JSON formats. - Implemented `rule_system_demo.py` to showcase rule engine capabilities with various examples. - Established core rule engine functionality in `rules.py` with support for conditions and actions. - Enhanced base plugin structure in `base.py` to support different plugin types (Processor, Renderer, Analyzer). - Added custom exception handling in `exceptions.py` for better error management. - Configured logging setup in `logging_config.py` for improved logging capabilities. - Created unit tests in `test_rust_core.py` to validate core functionalities and performance. --- tests/test_rule_extractor.py | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'tests/test_rule_extractor.py') diff --git a/tests/test_rule_extractor.py b/tests/test_rule_extractor.py index 6c4d585..2c2815c 100644 --- a/tests/test_rule_extractor.py +++ b/tests/test_rule_extractor.py @@ -1,8 +1,3 @@ -#!/usr/bin/env python3 -""" -RuleExtractor 模块单元测试 -""" - import unittest import tempfile import json5 @@ -11,11 +6,7 @@ from conventionalrp.extractors.rule_extractor import RuleExtractor class TestRuleExtractor(unittest.TestCase): - """RuleExtractor 类的单元测试""" - def setUp(self): - """设置测试环境""" - # 创建临时规则文件 self.temp_rules = tempfile.NamedTemporaryFile( mode='w', suffix='.json5', @@ -30,23 +21,19 @@ class TestRuleExtractor(unittest.TestCase): self.temp_rules.close() def tearDown(self): - """清理测试环境""" Path(self.temp_rules.name).unlink(missing_ok=True) def test_init_without_file(self): - """测试不带配置文件的初始化""" extractor = RuleExtractor() self.assertEqual(extractor.rules, {}) self.assertIsNone(extractor.config_file) def test_init_with_file(self): - """测试带配置文件的初始化""" extractor = RuleExtractor(self.temp_rules.name) self.assertIsNotNone(extractor.rules) self.assertIn("test_rule", extractor.rules) def test_load_rules_from_file_success(self): - """测试成功加载规则文件""" extractor = RuleExtractor() rules = extractor.load_rules_from_file(self.temp_rules.name) @@ -55,13 +42,11 @@ class TestRuleExtractor(unittest.TestCase): self.assertEqual(rules["test_rule"], "test_value") def test_load_rules_from_file_not_found(self): - """测试加载不存在的文件""" extractor = RuleExtractor() with self.assertRaises(FileNotFoundError): extractor.load_rules_from_file("nonexistent.json5") def test_load_rules_empty_file(self): - """测试加载空文件""" empty_file = tempfile.NamedTemporaryFile( mode='w', suffix='.json5', @@ -79,7 +64,6 @@ class TestRuleExtractor(unittest.TestCase): Path(empty_file.name).unlink(missing_ok=True) def test_load_rules_method(self): - """测试 load_rules 方法""" extractor = RuleExtractor() rules = extractor.load_rules(self.temp_rules.name) @@ -87,7 +71,6 @@ class TestRuleExtractor(unittest.TestCase): self.assertEqual(extractor.rules, rules) def test_extract_method(self): - """测试 extract 方法""" extractor = RuleExtractor(self.temp_rules.name) extracted = extractor.extract() -- cgit v1.2.3-70-g09d2