Best Python code snippet using hypothesis
__init__.py
Source:__init__.py  
...75        i = self.start76        for c in s:77            i = self.transition(i, c)78        return self.is_accepting(i)79    def all_matching_regions(self, string):80        """Return all pairs ``(u, v)`` such that ``self.matches(string[u:v])``."""81        # Stack format: (k, state, indices). After reading ``k`` characters82        # starting from any i in ``indices`` the DFA would be at ``state``.83        stack = [(0, self.start, range(len(string)))]84        results = []85        while stack:86            k, state, indices = stack.pop()87            # If the state is dead, abort early - no point continuing on88            # from here where there will be no more matches.89            if self.is_dead(state):90                continue91            # If the state is accepting, then every one of these indices92            # has a matching region of length ``k`` starting from it.93            if self.is_accepting(state):...test_dfa.py
Source:test_dfa.py  
...104def test_all_matching_regions_include_all_matches(x, y, z):105    y_matcher = ConcreteDFA([{c: i + 1} for i, c in enumerate(y)] + [[]], {len(y)})106    assert y_matcher.matches(y)107    s = x + y + z108    assert (len(x), len(x) + len(y)) in y_matcher.all_matching_regions(s)109@pytest.mark.parametrize("n", [1, 10, 100, 1000])110def test_max_length_of_long_dfa(n):111    dfa = ConcreteDFA([{0: i + 1} for i in range(n)] + [{}], {n})112    assert not dfa.is_dead(dfa.start)113    assert dfa.max_length(dfa.start) == n114def test_dfa_with_cached_dead():115    dfa = ConcreteDFA([[{0: 1, 1: 2}], [], []], {2})116    assert dfa.is_dead(1)117    assert dfa.is_dead(0)118@pytest.mark.parametrize("order", itertools.permutations((0, 1, 2)))119def test_dead_nodes(order):120    dfa = ConcreteDFA([{0: 1, 1: 2}, {}, {}], {2})121    for i in order:122        assert dfa.is_dead(i) == (i == 1)...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
