Permalink
Browse files

DocumentationCommentTest: Refactor

  • Loading branch information...
SanketDG committed Jun 25, 2016
1 parent 91a32dc commit 99fa059f9d4f1d5a8f2b1099f208b5848b5a1222
Showing with 24 additions and 18 deletions.
  1. +24 −18 tests/bearlib/languages/documentation/DocumentationCommentTest.py
@@ -9,6 +9,24 @@
class DocumentationCommentTest(unittest.TestCase):
Description = DocumentationComment.Description
Parameter = DocumentationComment.Parameter
ReturnValue = DocumentationComment.ReturnValue
def load_testdata(self, filename):
filename = os.path.join(os.path.dirname(
os.path.realpath(__file__)),
os.path.join("documentation_extraction_testdata",
filename))
with open(filename, "r") as test_file:
data = test_file.read()
return data.splitlines(keepends=True)
class GeneralDocumentationCommentTest(DocumentationCommentTest):
def test_fields(self):
uut = DocumentationComment("my doc",
"c",
@@ -40,12 +58,14 @@ def test_fields(self):
self.assertEqual(uut.marker, ("##", "#", "#"))
self.assertEqual(uut.range, None)
def test_not_implemented(self):
not_implemented = DocumentationComment(
"some docs", "nolang", "doxygen", None, None, None)
with self.assertRaises(NotImplementedError):
not_implemented.parse()
class PythonDocumentationCommentTest(unittest.TestCase):
Description = DocumentationComment.Description
Parameter = DocumentationComment.Parameter
ReturnValue = DocumentationComment.ReturnValue
class PythonDocumentationCommentTest(DocumentationCommentTest):
def check_docstring(self, docstring, expected=[]):
self.assertIsInstance(docstring,
@@ -61,14 +81,6 @@ def check_docstring(self, docstring, expected=[]):
parsed_metadata = doc_comment.parse()
self.assertEqual(parsed_metadata, expected)
def load_testdata(self, filename):
filename = (os.path.dirname(os.path.realpath(__file__)) +
"/documentation_extraction_testdata/" + filename)
with open(filename, "r") as fl:
data = fl.read()
return data.splitlines(keepends=True)
def test_empty_docstring(self):
self.check_docstring("", [])
@@ -142,9 +154,3 @@ def test_python_doxygen(self):
self.ReturnValue(desc='Nothing\n')]]
self.assertEqual(parsed_docs, expected)
def test_not_implemented(self):
not_implemented = DocumentationComment("some docs", "nolang", "doxygen",
None, None, None)
with self.assertRaises(NotImplementedError):
not_implemented.parse()

0 comments on commit 99fa059

Please sign in to comment.