import pytest import re from soundchanger.change import apply def test_error_in_change(): # with pytest.raises(ValueError, match=re.escape("Change is not a valid sound change. (Missing character '>')")): with pytest.raises(ValueError, match=re.escape("Change is not a valid sound change.")): apply('', '', ignore_errors=False) def test_error_split(): # with pytest.raises(ValueError, match=re.escape("Change a>b/c/d is not a valid sound change. (More than one '/' character)")): with pytest.raises(ValueError, match=re.escape("Change a>b/c/d is not a valid sound change.")): apply('a>b/c/d', '', ignore_errors=False) def test_error_in_environment(): # with pytest.raises(ValueError, match=re.escape("Environment c is not a valid environment. (Character '_' should exist exactly once)")): with pytest.raises(ValueError, match=re.escape("Change a>b/c is not a valid sound change.")): apply('a>b/c', '', ignore_errors=False) def test_no_change_from(): # with pytest.raises(ValueError, match=re.escape("Nothing to change from.")): with pytest.raises(ValueError, match=re.escape("Change >b is not a valid sound change.")): apply('>b', '', ignore_errors=False)