-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: make OutputChecker pluggable #141
Conversation
cc @Sheila-nk |
Note to self: with this and alternate DTParsers, the docs should shift the focus a bit. First discuss that everything is pluggable (Checker, Parser, Finder), then get on to the fp-aware Checker. Now that I think of it, the Finder is a bit different: the main logic is in |
@@ -340,7 +343,7 @@ def __init__(self, checker=None, verbose=None, optionflags=None, config=None): | |||
if config is None: | |||
config = DTConfig() | |||
if checker is None: | |||
checker = DTChecker(config) | |||
checker = config.CheckerKlass(config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great idea. However, the implementation currently does not make the Checker pluggable since doctest.OutputChecker
has no __init__
function and can therefore not take any config
argument like DTChecker
.
Any attempt to use the Vanilla OutputChecker will fail:
checker = config.CheckerKlass(config)
E TypeError: OutputChecker() takes no arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is OutputChecker here, is it doctest.OutputChecker
? Then indeed, it'll fail. ISTM the best we can do is to document the story: "Any admissible OutputChecker must have __init__(self, config)
".
Maybe before we get to this, we can override the vanilla OutputChecker to have an __init__function like you did during testing. What do you think? |
Not sure what OutputChecker you mean? |
Merged it, thanks for the review Sheila! |
Add CheckerKlass attribute to DTConfig for the class name of the Checker, use in instantiating the Runner. Then it percolates all the way up to all sorts of frontends, both doctest and pytest layers.
DTConfig gets a bit crowded, and it becomes easy to silently ignore some keys: VanillaOutputChecker ignores atol/rtol etc. If this ever becomes a problem, can add more structure to DTConfig.
The right thing is likely to make DTConfig hold actual objects not classes and their instantiation parameters.
That would be a larger change though, so let's get there when it gets more usage.
Until then, let's keep it simple.
cross-ref gh-38.