def test_command_return_value(): """"[bug] Check the return value is passed through ok.""" class FooCommand(management.NoArgsCommand): def handle_noargs(self, **options): pass print management.call_command(FooCommand()) assert management.call_command(FooCommand()) == 0 # TODO: test the command return value is printed
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')