def _call_start(addins_to_test, *args, **options): addins.reinstall(addins=addins_to_test) management.reload_commands() old_sys = sys.stdout old_err = sys.stderr sys.stdout = sys.stderr = StringIO.StringIO() try: management.call_command('start', *args, **options) sys.stdout.seek(0) return sys.stdout.read().strip() finally: sys.stdout = old_sys sys.stderr = old_err
def test_commands(): """Addins may provide commands.""" class FooCommand(management.NoArgsCommand): def handle_noargs(self, **options): return 1 class foo(addins.base): def get_commands(self): return { 'foo': FooCommand, } addins.reinstall((foo,)) management.reload_commands() management.call_command('foo')