spacepaste

  1.  
  2. import click
  3. class MyCLI(click.MultiCommand):
  4. def list_commands(self, ctx):
  5. print('A')
  6. assert ctx.obj is not None, 'A'
  7. def get_command(self, ctx, name):
  8. print('B')
  9. assert ctx.obj is not None, 'B'
  10. @click.command(cls=MyCLI)
  11. @click.pass_context
  12. def cli(ctx):
  13. ctx.obj = 123
  14. if __name__ == '__main__':
  15. cli()
  16. cmd = self.get_command(ctx, cmd_name)
  17. File "cli4.py", line 11, in get_command
  18. assert ctx.obj is not None, 'B'
  19. AssertionError: B
  20.