Best Python code snippet using fMBT_python
test_cscvg76186.py
Source:test_cscvg76186.py  
...63        assert CSCvg76186.remediate_implemented() is False64    def test_check_bug_unaffected1(self, bug, mock_connection):65        """ Test check_bug method with an unaffected device """66        mock_connection.vstack_output = unaffected_output167        result = bug.check_bug(mock_connection)68        assert result.impacted is False69    def test_check_bug_unaffected2(self, bug, mock_connection):70        """ Test check_bug method with an unaffected device """71        mock_connection.vstack_output = unaffected_output272        result = bug.check_bug(mock_connection)73        assert result.impacted is False74    def test_check_bug_affected1(self, bug, mock_connection):75        """ Test check_bug method with an affected device """76        mock_connection.vstack_output = affected_output177        result = bug.check_bug(mock_connection)78        assert result.impacted is True79    def test_check_bug_affected2(self, bug, mock_connection):80        """ Test check_bug method with an affected device """81        mock_connection.vstack_output = affected_output282        result = bug.check_bug(mock_connection)83        assert result.impacted is True84    def test_check_bug_command_not_supported(self, bug, mock_connection):85        """ Check check_bug method output returns not supported when it is unable to get vstack output"""86        result = bug.check_bug(mock_connection)87        assert result.impacted is False88        assert result.output == not_supported89    def test_remediate(self, bug):90        """ Test remediate method not implemented """91        with pytest.raises(Exception):...snake.py
Source:snake.py  
...45                RADIUS)46        pygame.draw.circle(SCREEN, (0, 255, 0), (self.headx, self.heady),47            RADIUS)48        pygame.display.flip()49        self.check_bug()50    def check_dead(self):51        """check_dead function52        """53        if [self.headx, self.heady] in self.elements[1:]:54            exit_dead()55        if [self.headx, self.heady] in WALL:56            exit_dead()57    def check_bug(self):58        """check_bug function59        """60        if (self.headx, self.heady) == BUG:61            self.elements.append(self.elements[-1])62            create_bug()63def draw_map():64    """draw_map function65    """66    for n in range(20, RES[0], 20):67        pygame.draw.circle(SCREEN, (0, 0, 255), (n, 20), 10)68        WALL.append([n, 20])69        pygame.draw.circle(SCREEN,(0, 0, 255),(n, RES[1] - 20), 10)70        WALL.append([n, RES[1] - 20])71    for n in range(20, RES[1], 20):...Test01 Check.py
Source:Test01 Check.py  
1import re2def main():3    # check_qq()4    # check_phone()5    # check_bug()6    check_poem()7def check_qq():8    username = input('请è¾å
¥ç¨æ·å: ')9    qq = input('请è¾å
¥QQå·: ')10    # match彿°ç第ä¸ä¸ªåæ°æ¯æ£å表达å¼åç¬¦ä¸²ææ£å表达å¼å¯¹è±¡11    # 第äºä¸ªåæ°æ¯è¦è·æ£å表达å¼åå¹é
çå符串对象12    m1 = re.match(r'^[0-9a-zA-Z_]{6,20}$', username)13    if not m1:14        print('请è¾å
¥ææçç¨æ·å.')15    m2 = re.match(r'^[1-9]\d{4,11}$', qq)16    if not m2:17        print('请è¾å
¥ææçQQå·.')18    if m1 and m2:19        print('ä½ è¾å
¥çä¿¡æ¯æ¯ææç!')20def check_phone():21    # å建æ£å表达å¼å¯¹è±¡ 使ç¨äºåç»åå顾æ¥ä¿è¯ææºå·ååä¸åºè¯¥åºç°æ°å22    pattern = re.compile(r'(?<=\D)(1[38]\d{9}|14[57]\d{8}|15[0-35-9]\d{8}|17[678]\d{8})(?=\D)')23    sentence = '''24    éè¦çäºæ
说8130123456789éï¼æçææºå·æ¯13512346789è¿ä¸ªéå·ï¼25    䏿¯15600998765ï¼ä¹æ¯110æ119ï¼ç大é¤çææºå·ææ¯15600998765ã26    '''27    # æ¥æ¾ææå¹é
å¹¶ä¿åå°ä¸ä¸ªå表ä¸28    my_list = re.findall(pattern, sentence)29    print(my_list)30    print('--------å丽çåé线--------')31    # éè¿è¿ä»£å¨ååºå¹é
对象并è·å¾å¹é
çå
容32    for temp in pattern.finditer(sentence):33        print(temp.group())34    print('--------å丽çåé线--------')35    # éè¿search彿°æå®æç´¢ä½ç½®æ¾åºææå¹é
36    m = pattern.search(sentence)37    while m:38        print(m.group())39        m = pattern.search(sentence, m.end())40def check_bug():41    sentence = '你丫æ¯å»åå? ææä½ å¤§ç·ç. Fuck you.'42    purified = re.sub('[æèè¹]|fuck|shit|å»[æ¯å±é¼å缺åå±]|ç
ç¬',43                      '*', sentence, flags=re.IGNORECASE)44    print(purified)  # 你丫æ¯*å? æ*你大ç·ç. * you.45def check_poem():46    poem = 'çªåææå
ï¼çæ¯å°ä¸éãä¸¾å¤´æææï¼ä½å¤´ææ
乡ã'47    sentence_list = re.split(r'[ï¼ã, .]', poem)48    while '' in sentence_list:49        sentence_list.remove('')50    print(sentence_list)  # ['çªåææå
', 'çæ¯å°ä¸é', 'ä¸¾å¤´æææ', 'ä½å¤´ææ
乡']51if __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!!
