(self)
| 340 | self.assertEqual('my_method', page_info.methods[0].short_name) |
| 341 | |
| 342 | def test_docs_for_module(self): |
| 343 | |
| 344 | index = { |
| 345 | 'TestModule': |
| 346 | test_module, |
| 347 | 'TestModule.test_function': |
| 348 | test_function, |
| 349 | 'TestModule.test_function_with_args_kwargs': |
| 350 | test_function_with_args_kwargs, |
| 351 | 'TestModule.TestClass': |
| 352 | TestClass, |
| 353 | } |
| 354 | |
| 355 | visitor = DummyVisitor(index=index, duplicate_of={}) |
| 356 | |
| 357 | reference_resolver = parser.ReferenceResolver.from_visitor( |
| 358 | visitor=visitor, doc_index={}, py_module_names=['tf']) |
| 359 | |
| 360 | tree = { |
| 361 | 'TestModule': ['TestClass', 'test_function', |
| 362 | 'test_function_with_args_kwargs'] |
| 363 | } |
| 364 | parser_config = parser.ParserConfig( |
| 365 | reference_resolver=reference_resolver, |
| 366 | duplicates={}, |
| 367 | duplicate_of={}, |
| 368 | tree=tree, |
| 369 | index=index, |
| 370 | reverse_index={}, |
| 371 | guide_index={}, |
| 372 | base_dir='/') |
| 373 | |
| 374 | page_info = parser.docs_for_object( |
| 375 | full_name='TestModule', |
| 376 | py_object=test_module, |
| 377 | parser_config=parser_config) |
| 378 | |
| 379 | # Make sure the brief docstring is present |
| 380 | self.assertEqual( |
| 381 | tf_inspect.getdoc(test_module).split('\n')[0], page_info.doc.brief) |
| 382 | |
| 383 | # Make sure that the members are there |
| 384 | funcs = {f_info.obj for f_info in page_info.functions} |
| 385 | self.assertEqual({test_function, test_function_with_args_kwargs}, funcs) |
| 386 | |
| 387 | classes = {cls_info.obj for cls_info in page_info.classes} |
| 388 | self.assertEqual({TestClass}, classes) |
| 389 | |
| 390 | # Make sure the module's file is contained as the definition location. |
| 391 | self.assertEqual( |
| 392 | os.path.relpath(test_module.__file__.rstrip('c'), '/'), |
| 393 | page_info.defined_in.path) |
| 394 | |
| 395 | def test_docs_for_function(self): |
| 396 | index = { |
nothing calls this directly
no test coverage detected