Skip to content
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

Autoplugin will crash sphinx if the plugin crashes #354

Open
ptthiem opened this issue Oct 28, 2017 · 3 comments
Open

Autoplugin will crash sphinx if the plugin crashes #354

ptthiem opened this issue Oct 28, 2017 · 3 comments

Comments

@ptthiem
Copy link
Collaborator

ptthiem commented Oct 28, 2017

Currently, the autoplugin sphinx plugin will crash sphinx if a minimal setup will cause the plugin being documented to crash in its init. This is because the plugin is actually executed to get some basic information. We could catch errors and try printing out a warning, though, this behavior can be a bit surprising in any case because if a plugin author does not access all the configuration variables before the init finishes or throws an exception; then not all the parameters will get documented. I don't see an easy way to "fix" this without rethinking how this is done, but maybe we can add some guidance to the auto-plugin documentation to make it less surprising.

EDIT: Examples of things that can't really be supported by autoplugin as is:

def __init__(self):
    cfg1 = self.config.as_str('cfg1')
    # Something that crashes if cfg doesn't have a value
    cfg2 = self.config.as_Str('cfg2')
    # cfg2 doesn't get documented

or

def __init__(self):
    cfg1 = self.config.as_str('cfg1')
    if cfg1 == 'magic':
        cfg2 = self.config.as_Str('cfg2')
        # cfg2 doesn't get documented

Though, personally, I would extract all the configuration values first, and then override self.startTestRun() or self.pluginsLoaded() for anything that might crash or need to sys.exit().

@artragis
Copy link
Contributor

I think the first thing we can do is a "required" parameter to the as_int, as_list` etc. methods to say the attribute is mandatory. Then create a config method that prints all errors into stderr.

@ptthiem
Copy link
Collaborator Author

ptthiem commented Oct 28, 2017

You mean something that prints all missing configuration values when nose2 is run?

@artragis
Copy link
Contributor

When it is a "true" run, yes, and when it is autoplugin, it justs adds the notice "mandatory"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants