Testing Configuration Parameter Tracking in HanLP
This test suite validates the ConfigTracker functionality in HanLP, focusing on configuration parameter tracking and initialization behavior. The tests ensure proper inheritance and config storage mechanisms for class instantiation.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
hankcs/hanlp
tests/test_config_tracker.py
import unittest
from hanlp.common.structure import ConfigTracker
class MyClass(ConfigTracker):
def __init__(self, i_need_this='yes') -> None:
super().__init__(locals())
class TestConfigTracker(unittest.TestCase):
def test_init(self):
obj = MyClass()
self.assertEqual(obj.config.get('i_need_this', None), 'yes')
if __name__ == '__main__':
unittest.main()