Best Python code snippet using assertpy_python
task05.py
Source:task05.py
...120 for i in range(len(str)):121 if str[i] not in num:122 return False123 return True124def test_is_digit():125 msg = 'is_digit'126 isEquals(is_digit('123423424'), True, msg)127 isEquals(is_digit('gu a'), False, msg)128 isEquals(is_digit('1341gu a123242'), False, msg)129 pass130"""131 s æ¯ string132 è¿åä¸ä¸ªãå é¤äºå符串å¼å§çææç©ºæ ¼ãçå符串133 è¿å string134"""135def strip_left(str):136 if is_space(str): # å
¨é¨ä¸ºç©ºæ ¼137 return ''138 space = ' '139 if str[0] != space:140 return str141 index = 0 # é»è®¤ä¸º 0 ç©ºæ ¼çç´¢å¼142 for i in range(len(str)):143 if str[i] == space:144 index = i145 continue146 else:147 break148 index += 1149 r = str[index::]150 log('r', r)151 return r152def test_strip_left():153 msg = 'strip_left'154 isEquals(strip_left(' gua'), 'gua', msg)155 isEquals(strip_left('gua gua'), 'gua gua', msg)156 isEquals(strip_left(' gua gua'), 'gua gua', msg)157def strip_right(str):158 if is_space(str): # å
¨é¨ä¸ºç©ºæ ¼159 return ''160 space = ' '161 if str[len(str) - 1] != space:162 return str163 index = 0 # é»è®¤ä¸º 0 ç©ºæ ¼çç´¢å¼164 for i in range(len(str)):165 i = len(str) - 1 - i166 if str[i] == space:167 index = i168 continue169 else:170 break171 r = str[:index:]172 log('r', r)173 return r174def test_strip_right():175 msg = 'strip_right'176 isEquals(strip_right('gua '), 'gua', msg)177 isEquals(strip_right('gua gua'), 'gua gua', msg)178 isEquals(strip_right('gua gua '), 'gua gua', msg)179"""180 s æ¯ string181 è¿åä¸ä¸ªãå é¤äºå符串é¦å°¾çææç©ºæ ¼ãçå符串182 è¿å string183"""184def strip(str):185 return strip_left(strip_right(str))186def test_strip():187 msg = 'strip'188 isEquals(strip(' gua '), 'gua', msg)189 isEquals(strip(' gua gua'), 'gua gua', msg)190 isEquals(strip('gua '), 'gua', msg)191 isEquals(strip('gua gua'), 'gua gua', msg)192 isEquals(strip('gua gua '), 'gua gua', msg)193def main():194 test_zfill()195 test_ljust()196 test_rjust()197 test_center()198 test_is_space()199 test_is_digit()200 test_strip_left()201 test_strip_right()202 test_strip()203if __name__ == '__main__':...
_re.py
Source:_re.py
...4 pattern = re.compile('\A[+-]?[\d]+.?\d+\Z')5 if pattern.match(var):6 res = True7 return res8def test_is_digit():9 t_input = ['4.0O0', '-1.00', '+4.54', 'SomeRandomStuff']10 t_output = [False, True, True, False]11 assert [is_digit(x) for x in t_input] == t_output12test_is_digit()13if __name__ == '__main__':14 vars = [input().strip() for _ in range(int(input()))]15 for v in vars:...
test_is_digit.py
Source:test_is_digit.py
1from is_digit import is_digit2def test_is_digit():3 assert is_digit("s2324") is False4 assert is_digit("-234.4") is True5 assert is_digit("3 4") is False6 assert is_digit("3-4") is False7 assert is_digit("3 4 ") is False8 assert is_digit("34.65") is True9 assert is_digit("-0") is True10 assert is_digit("0.0") is True11 assert is_digit("") is False...
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!!