Пример #1
0
 def test_too_big_position_error(self, replace):
     with pytest.raises(IndexError):
         replace(a, (0, ), b)
     with pytest.raises(IndexError):
         replace(f(a), (0, 0), b)
     with pytest.raises(IndexError):
         replace(f(a), (1, ), b)
     with pytest.raises(IndexError):
         replace(f(a, b), (2, ), b)
Пример #2
0
 def test_substitution_match(self, replace, expression, position, replacement, expected_result):
     result = replace(expression, position, replacement)
     assert result == expected_result, "Replacement did not yield expected result ({!r} {!r} -> {!r})".format(
         expression, position, replacement
     )
     assert result is not expression, "Replacement modified the original expression"