def test_compose_command(): @compose_command() def test_command(self): """ Test command Usage: config [options] Options: -o, --option Option """ return True @compose_command(standalone=True) def stest_command(self): """ Second test command Usage: config [options] Options: -o, --option Option """ return False if hasattr(TopLevelCommand, '__modified_doc__'): assert re.search( r'test_command\s+Test command', TopLevelCommand.__modified_doc__ ) is not None assert re.search( r'stest_command\s+Second test command', TopLevelCommand.__modified_doc__ ) is not None else: assert re.search( r'test_command\s+Test command', TopLevelCommand.__doc__ ) is not None assert re.search( r'stest_command\s+Second test command', TopLevelCommand.__doc__ ) is not None top_level_command = TopLevelCommand(None, None, None) assert TopLevelCommand.test_command.__standalone__ is False assert TopLevelCommand.stest_command.__standalone__ is True assert top_level_command.test_command() is True assert top_level_command.stest_command() is False with pytest.raises(PluginCommandError): test_command(None) with pytest.raises(PluginCommandError): stest_command(None)