Created
July 30, 2013 13:38
-
-
Save arnaudbos/6112991 to your computer and use it in GitHub Desktop.
Django command wrapper
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
| from optparse import OptionParser | |
| from myapp.management.commands import my_command | |
| def make_test_wrapper_for(command_module): | |
| def _run_cmd_with(*args): | |
| """Run the possibly_add_alert command with the supplied arguments""" | |
| cmd = command_module.Command() | |
| (opts, args) = OptionParser(option_list=cmd.option_list).parse_args(list(args)) | |
| cmd.handle(*args, **vars(opts)) | |
| return _run_cmd_with | |
| cmd_runner = make_test_wrapper_for(my_command) | |
| cmd_runner("foo", "bar") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment