usse/scrape/venv/lib/python3.10/site-packages/esbonio/server/testing.py
2023-12-22 15:26:01 +01:00

15 lines
429 B
Python

"""Helpers and utilities for writing tests."""
from lsprotocol import types
def range_from_str(spec: str) -> types.Range:
"""Create a range from the given string ``a:b-x:y``"""
start, end = spec.split("-")
sl, sc = start.split(":")
el, ec = end.split(":")
return types.Range(
start=types.Position(line=int(sl), character=int(sc)),
end=types.Position(line=int(el), character=int(ec)),
)