This repository was archived by the owner on Apr 4, 2025. It is now read-only.
Open
Conversation
Owner
|
wow, I can't believe people use this, not to mention actually put up a PR! Thanks for this! |
Author
|
My tests don't have classes, so I got lines with only In my formatter I also handle multiline docstrings. Here it is: from pytest_docs.formatter import Formatter
from textwrap import dedent
class CustomFormatter(Formatter):
name = "custom"
marker_prefix = ""
@staticmethod
def module_name_format(element):
return "# {}".format(element)
@staticmethod
def class_name_format(element):
if str(element) == "":
return ""
return "## Class {}".format(element)
@staticmethod
def func_name_format(element):
return "## {}".format(element)
@staticmethod
def marker_format(marker):
return ""
@staticmethod
def func_desc_format(element):
return dedent(str(element)).lstrip("\n") |
Owner
|
hmm, I'm a bit hesitant to introduce such a direct import mechanism system to support this use type. I think refactoring the existing formatter to be plugins and loaded as such would be better, as it will allow any user just creating new ones on their end without needing new code changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
I have expanded the pytest options with
--custom-formatter-pathwhere you can input a module path to a file containing the classCustomFormatter.