(self)
| 148 | '<a href="../somewhere/else">Two words</a>', result) |
| 149 | |
| 150 | def test_docs_for_class(self): |
| 151 | |
| 152 | index = { |
| 153 | 'TestClass': TestClass, |
| 154 | 'TestClass.a_method': TestClass.a_method, |
| 155 | 'TestClass.a_property': TestClass.a_property, |
| 156 | 'TestClass.ChildClass': TestClass.ChildClass, |
| 157 | 'TestClass.CLASS_MEMBER': TestClass.CLASS_MEMBER |
| 158 | } |
| 159 | |
| 160 | visitor = DummyVisitor(index=index, duplicate_of={}) |
| 161 | |
| 162 | reference_resolver = parser.ReferenceResolver.from_visitor( |
| 163 | visitor=visitor, doc_index={}, py_module_names=['tf']) |
| 164 | |
| 165 | tree = { |
| 166 | 'TestClass': ['a_method', 'a_property', 'ChildClass', 'CLASS_MEMBER'] |
| 167 | } |
| 168 | parser_config = parser.ParserConfig( |
| 169 | reference_resolver=reference_resolver, |
| 170 | duplicates={}, |
| 171 | duplicate_of={}, |
| 172 | tree=tree, |
| 173 | index=index, |
| 174 | reverse_index={}, |
| 175 | guide_index={}, |
| 176 | base_dir='/') |
| 177 | |
| 178 | page_info = parser.docs_for_object( |
| 179 | full_name='TestClass', py_object=TestClass, parser_config=parser_config) |
| 180 | |
| 181 | # Make sure the brief docstring is present |
| 182 | self.assertEqual( |
| 183 | tf_inspect.getdoc(TestClass).split('\n')[0], page_info.doc.brief) |
| 184 | |
| 185 | # Make sure the method is present |
| 186 | self.assertEqual(TestClass.a_method, page_info.methods[0].obj) |
| 187 | |
| 188 | # Make sure that the signature is extracted properly and omits self. |
| 189 | self.assertEqual(["arg='default'"], page_info.methods[0].signature) |
| 190 | |
| 191 | # Make sure the property is present |
| 192 | self.assertIs(TestClass.a_property, page_info.properties[0].obj) |
| 193 | |
| 194 | # Make sure there is a link to the child class and it points the right way. |
| 195 | self.assertIs(TestClass.ChildClass, page_info.classes[0].obj) |
| 196 | |
| 197 | # Make sure this file is contained as the definition location. |
| 198 | self.assertEqual(os.path.relpath(__file__, '/'), page_info.defined_in.path) |
| 199 | |
| 200 | def test_namedtuple_field_order(self): |
| 201 | namedtupleclass = collections.namedtuple('namedtupleclass', |
nothing calls this directly
no test coverage detected