MCPcopy
hub / github.com/sphinx-doc/sphinx / TestGroup

Class TestGroup

sphinx/ext/doctest.py:200–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198
199
200class TestGroup:
201 def __init__(self, name: str) -> None:
202 self.name = name
203 self.setup: list[TestCode] = []
204 self.tests: list[list[TestCode] | tuple[TestCode, None]] = []
205 self.cleanup: list[TestCode] = []
206
207 def add_code(self, code: TestCode, prepend: bool = False) -> None:
208 if code.type == 'testsetup':
209 if prepend:
210 self.setup.insert(0, code)
211 else:
212 self.setup.append(code)
213 elif code.type == 'testcleanup':
214 self.cleanup.append(code)
215 elif code.type == 'doctest':
216 self.tests.append([code])
217 elif code.type == 'testcode':
218 # "testoutput" may replace the second element
219 self.tests.append((code, None))
220 elif code.type == 'testoutput':
221 if self.tests:
222 latest_test = self.tests[-1]
223 if len(latest_test) == 2:
224 self.tests[-1] = [latest_test[0], code]
225 else:
226 raise RuntimeError(__('invalid TestCode type'))
227
228 def __repr__(self) -> str:
229 return (
230 f'TestGroup(name={self.name!r}, setup={self.setup!r}, '
231 f'cleanup={self.cleanup!r}, tests={self.tests!r})'
232 )
233
234
235class TestCode:

Callers 1

test_docMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_docMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…