Best Python code snippet using prospector_python
test_plan.py
Source:test_plan.py  
...198                [1, "Run Tests", False, False],199            ],200        )201    @mock.patch("cumulusci.cli.plan.CliTable")202    def test_plan_info__messages_only(self, cli_table, runtime):203        """Verify that --messages results in only messages being output"""204        run_click_command(plan.plan_info, "plan 1", runtime=runtime, messages_only=True)205        cli_table.assert_called_once_with(206            title="Messages",207            data=[208                ["Type", "Message"],209                ["Title", "Test Plan #1"],210                ["Preflight", "This is a preflight message"],211                ["Post-install", ""],212                ["Error", "This is an error message"],213            ],214        )215    def test_plan_info__bogus_plan(self, runtime):216        """Verify a missing play causes a useful message"""...SaveMessages.py
Source:SaveMessages.py  
1from TwitchWebsocket import TwitchWebsocket2import random, time, json, logging, os3from Log import Log4Log(__file__)5from Settings import Settings6from Database import Database7class SaveMessage:8    def __init__(self):9        self.host = None10        self.port = None11        self.chan = None12        self.nick = None13        self.auth = None14        self.messages_only = None15        self.last_message_t = time.time()16        17        # Fill previously initialised variables with data from the settings.txt file18        Settings(self)19        self.db = Database()20        21        self.ws = TwitchWebsocket(host=self.host, 22                                  port=self.port,23                                  chan=self.chan,24                                  nick=self.nick,25                                  auth=self.auth,26                                  callback=self.message_handler,27                                  capability=["membership", "tags", "commands"],28                                  live=True)29        self.ws.start_bot()30    def setSettings(self, host, port, chan, nick, auth, messages_only):31        self.host = host32        self.port = port33        self.chan = chan34        self.nick = nick35        self.auth = auth36        self.messages_only = messages_only37    def message_handler(self, m):38        try:39            if m.type == "366":40                logging.info(f"Successfully joined channel: #{m.channel}")41            elif m.type == "PRIVMSG" or not self.messages_only:42                self.add_message_to_db(m, time.time() - self.last_message_t)43                self.last_message_t = time.time()44        except Exception as e:45            logging.error(e)46            47    def add_message_to_db(self, m, time_since_last):48        self.db.add_item(m.full_message, json.dumps(m.tags), m.command, m.user, m.type, m.params, m.channel, m.message, round(self.last_message_t), time_since_last)49if __name__ == "__main__":...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
