def testParseFunctionDetails(self): docstring, function_details = parser._parse_function_details(RELU_DOC) self.assertEqual(len(function_details), 2) args = function_details[0] self.assertEqual(args.keyword, 'Args') self.assertEmpty(args.header) self.assertEqual(len(args.items), 2) self.assertEqual(args.items[0][0], 'features') self.assertEqual(args.items[1][0], 'name') self.assertEqual(args.items[1][1], ' A name for the operation (optional)\n\n') returns = function_details[1] self.assertEqual(returns.keyword, 'Returns') relu_doc_lines = RELU_DOC.split('\n') self.assertEqual(docstring, relu_doc_lines[0] + '\n\n') self.assertEqual(returns.header, relu_doc_lines[-2] + '\n') self.assertEqual( RELU_DOC, docstring + ''.join(str(detail) for detail in function_details))
def test_parse_function_details(self): docstring, function_details = parser._parse_function_details(RELU_DOC) self.assertEqual(len(function_details), 2) args = function_details[0] self.assertEqual(args.keyword, 'Args') self.assertEqual(len(args.header), 0) self.assertEqual(len(args.items), 2) self.assertEqual(args.items[0][0], 'features') self.assertEqual(args.items[1][0], 'name') self.assertEqual(args.items[1][1], 'A name for the operation (optional)\n\n') returns = function_details[1] self.assertEqual(returns.keyword, 'Returns') relu_doc_lines = RELU_DOC.split('\n') self.assertEqual(docstring, relu_doc_lines[0] + '\n\n') self.assertEqual(returns.header, relu_doc_lines[-2] + '\n') self.assertEqual( RELU_DOC, docstring + ''.join(str(detail) for detail in function_details))