aboutsummaryrefslogtreecommitdiff
path: root/tests/builder/conflict.test.py
blob: b683c06b9b85fb4de6ef70911f9b798d9212751f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Tests for anchor conflicts when subexpressions merge with ``ignore_start_and_end=False``."""

import pytest

from edify import RegexBuilder
from edify.errors.anchors import EndInputAlreadyDefinedError, StartInputAlreadyDefinedError


def test_parent_with_start_merging_sub_with_start_raises():
    sub = RegexBuilder().start_of_input().digit()
    parent = RegexBuilder().start_of_input().digit()
    with pytest.raises(StartInputAlreadyDefinedError):
        parent.subexpression(sub, ignore_start_and_end=False)


def test_parent_with_end_merging_sub_with_end_raises():
    sub = RegexBuilder().digit().end_of_input()
    parent = RegexBuilder().digit().end_of_input()
    with pytest.raises(EndInputAlreadyDefinedError):
        parent.subexpression(sub, ignore_start_and_end=False)