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

Tests should use argument parser when calling commands #301

Closed
pv opened this issue Aug 10, 2015 · 3 comments
Closed

Tests should use argument parser when calling commands #301

pv opened this issue Aug 10, 2015 · 3 comments

Comments

@pv
Copy link
Collaborator

pv commented Aug 10, 2015

Calling Command.run directly leaves the main code path that's actually used untested, cf. gh-298

It could be useful to test the whole stack and use the actual command line parser for launching commands in the tests. It's probably possible to write a small helper function that takes a conf object etc. plus command line arguments, and uses those to launch commands.

@qwhelan
Copy link
Contributor

qwhelan commented Aug 11, 2015

The outermost run method is Command.run_from_args(), which looks looks like this (except update and quickstart, which map to Command.run()):

    @classmethod
    def run_from_args(cls, args):
        from ..plugin_manager import plugin_manager
        conf = config.Config.load(args.config)
        for plugin in conf.plugins:
            plugin_manager.import_plugin(plugin)
        return cls.run_from_conf_args(conf, args)

The issues I see are:

  • Every test will be reading args.config from disk, which will require some tempdir creation/cleanup logic.
  • More critically, every test will be importing anything included in conf.plugins, which could make testing behavior dependent upon presence/absence of particular plugins tricky.

@pv
Copy link
Collaborator Author

pv commented Aug 22, 2015

I was thinking about a helper function that calls run_from_conf_args based on conf + argv.

@pv
Copy link
Collaborator Author

pv commented Sep 27, 2015

Another such bug found in gh-324.
gh-325 attempts to make it certain no more arise.

@pv pv closed this as completed Sep 28, 2015
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