mirror of
https://github.com/macaodha/batdetect2.git
synced 2025-06-29 22:51:58 +02:00
Add test that ensures example_config is valid
This commit is contained in:
parent
d67ae9be05
commit
16febed792
@ -25,17 +25,6 @@ class BaseConfig(BaseModel):
|
|||||||
|
|
||||||
Inherits from Pydantic's `BaseModel` to provide data validation, parsing,
|
Inherits from Pydantic's `BaseModel` to provide data validation, parsing,
|
||||||
and serialization capabilities.
|
and serialization capabilities.
|
||||||
|
|
||||||
It sets `extra='forbid'` in its model configuration, meaning that any
|
|
||||||
fields provided in a configuration file that are *not* explicitly defined
|
|
||||||
in the specific configuration schema will raise a validation error. This
|
|
||||||
helps catch typos and ensures configurations strictly adhere to the expected
|
|
||||||
structure.
|
|
||||||
|
|
||||||
Attributes
|
|
||||||
----------
|
|
||||||
model_config : ConfigDict
|
|
||||||
Pydantic model configuration dictionary. Set to forbid extra fields.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model_config = ConfigDict(extra="ignore")
|
model_config = ConfigDict(extra="ignore")
|
||||||
|
10
tests/test_train/test_config.py
Normal file
10
tests/test_train/test_config.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from batdetect2.configs import load_config
|
||||||
|
from batdetect2.train import FullTrainingConfig
|
||||||
|
|
||||||
|
|
||||||
|
def test_example_config_is_valid(example_data_dir):
|
||||||
|
conf = load_config(
|
||||||
|
example_data_dir / "config.yaml",
|
||||||
|
schema=FullTrainingConfig,
|
||||||
|
)
|
||||||
|
assert isinstance(conf, FullTrainingConfig)
|
Loading…
Reference in New Issue
Block a user