plesna/tests/libs/test_string_tools.py

19 lines
541 B
Python
Raw Normal View History

2025-01-05 09:46:30 +00:00
import pytest
from plesna.libs.string_tools import StringToolsError, extract_values_from_pattern
def test_extract_values_from_pattern():
source = "id:truc-bidule-machin"
pattern = "id:{champ1}-{champ2}-machin"
assert extract_values_from_pattern(pattern, source) == {"champ1": "truc", "champ2": "bidule"}
def test_extract_values_from_pattern_no_match():
source = "id:truc-bidule"
pattern = "id:{champ1}-{champ2}-machin"
with pytest.raises(StringToolsError):
extract_values_from_pattern(pattern, source)