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

Function test_class

tests/test_pycode/test_pycode_parser.py:226–259  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

224
225
226def test_class() -> None:
227 source = (
228 'class Foo(object):\n'
229 ' attr1 = None #: comment1\n'
230 ' attr2 = None #: comment2\n'
231 '\n'
232 ' def __init__(self):\n'
233 ' self.a = 1 + 1 #: comment3\n'
234 ' self.attr2 = 1 + 1 #: overridden\n'
235 ' b = 1 + 1 #: comment5\n'
236 '\n'
237 ' def some_method(self):\n'
238 ' c = 1 + 1 #: comment6\n'
239 )
240 parser = Parser(source)
241 parser.parse()
242 assert parser.comments == {
243 ('Foo', 'attr1'): 'comment1',
244 ('Foo', 'a'): 'comment3',
245 ('Foo', 'attr2'): 'overridden',
246 }
247 assert parser.definitions == {
248 'Foo': ('class', 1, 11),
249 'Foo.__init__': ('def', 5, 8),
250 'Foo.some_method': ('def', 10, 11),
251 }
252 assert parser.deforders == {
253 'Foo': 0,
254 'Foo.attr1': 1,
255 'Foo.__init__': 3,
256 'Foo.a': 4,
257 'Foo.attr2': 5,
258 'Foo.some_method': 6,
259 }
260
261
262def test_class_uses_non_self() -> None:

Callers

nothing calls this directly

Calls 2

parseMethod · 0.95
ParserClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…