I am using pytest to check for multi-line docstrings and the way I am testing to check for these multi-line comments involves making a temp file and using write()
to write the docstring in and then search for it.
def test_file_contains_multiline_python_comment_count(tmpdir):
"""Checks that the multiline python comment count works"""
hello_file = tmpdir.mkdir("subdirectory").join("Hello.py")
hello_file.write(""" hello \n world """)
assert hello_file.read() == """ hello \n world """
assert len(tmpdir.listdir()) == 1
comment_count = entities.count_entities(
hello_file.basename, hello_file.dirname, comments.count_multiline_python_comment
)
assert comment_count == 1
However I am unable to figure out how to write the actual docstring. For example, """hello"""
would simply show up as hello