Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/jedi/common.py: 27%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from contextlib import contextmanager
4@contextmanager
5def monkeypatch(obj, attribute_name, new_value):
6 """
7 Like pytest's monkeypatch, but as a value manager.
8 """
9 old_value = getattr(obj, attribute_name)
10 try:
11 setattr(obj, attribute_name, new_value)
12 yield
13 finally:
14 setattr(obj, attribute_name, old_value)
17def indent_block(text, indention=' '):
18 """This function indents a text block with a default of four spaces."""
19 temp = ''
20 while text and text[-1] == '\n':
21 temp += text[-1]
22 text = text[:-1]
23 lines = text.split('\n')
24 return '\n'.join(map(lambda s: indention + s, lines)) + temp