Я использую pytest для проверки многострочных строк документации, и способ, которым я проверяю проверку этих многострочных комментариев, включает создание временного файла и использование write()
для записи строки документации, а затем поиск по ней.
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
Однако я не могу понять, как написать фактическую строку документации.Например, """hello"""
будет просто отображаться как hello