Best Python code snippet using pytest
assessment_test.py
Source:assessment_test.py
1import pytest2from Code import python13def test_one():4 assert python1.one("hi","hello") == "hello"5 assert python1.one("three", "two") == "three"6 assert python1.one("three", "hello") == "three hello"7 assert python1.one("echo", "print") == "print"8 assert python1.one("fire","rib") == "fire"9def test_two():10 assert python1.two("bertclivebert") == "clive"11 assert python1.two("xxbertfridgebertyy") == "fridge"12 assert python1.two("xxBertfridgebERtyy") == "fridge"13 assert python1.two("xxbertyy") == ""14 assert python1.two("xxbeRTyy") == ""15def test_three():16 assert python1.three(3) == "fizz"17 assert python1.three(10) == "buzz"18 assert python1.three(15) == "fizzbuzz"19 assert python1.three(8) == "null"20 assert python1.three(75) == "fizzbuzz"21def test_four():22 assert python1.four("55 72 86") == 1423 assert python1.four("15 72 80 164") == 1124 assert python1.four("555 72 86 45 10") == 1525 assert python1.four("98 63 34 1 13") == 1726 assert python1.four("98 107 415") == 1727def test_five():28 assert python1.five("Jeff,random.py,False,1445") == ["Jeff"]29 assert python1.five("Bert,numberGen.py,True,1447,Bert,integers.py,True,1318,Jeff,floats.py,False,1445") == ["Jeff"]30 assert python1.five("Bert,boolean.py,False,1447,Bert,conditions.py,False,1318,Jeff,loops.py,False,1445") == ["Bert","Jeff"]31 assert python1.five("Bert,prime.py,True,1447,Bert,ISBN.py,False,1318,Jeff,OOP.py,False,1445") == ["Bert","Jeff"]32 assert python1.five("Bert,files.py,True,1447,Bert,tests.py,True,1318,Jeff,app.py,True,1445") == []33def test_six():34 assert python1.six("ceiling") == True35 assert python1.six("believe") == True36 assert python1.six("glacier") == False37 assert python1.six("height") == False38 assert python1.six("receive") == True39def test_seven():40 assert python1.seven("Hello") == 2 41 assert python1.seven("hEelLoooO") == 642 assert python1.seven("WhitEboarD") == 443 assert python1.seven("as") == 144 assert python1.seven("pass") == 145def test_eight():46 assert python1.eight(1) == 147 assert python1.eight(3) == 648 assert python1.eight(4) == 2449 assert python1.eight(6) == 72050 assert python1.eight(8) == 4032051def test_nine():52 assert python1.nine("This is a Sentence","s") == 453 assert python1.nine("This is a Sentence","S") == 854 assert python1.nine("Fridge for sale","z") == -155 assert python1.nine("I love Python", "L") == -156 assert python1.nine("I LOVE PYTHON", "L") == 257def test_ten():58 assert python1.ten("The",2,"h") == True59 assert python1.ten("AAbb",1,"b") == False60 assert python1.ten("Hi-There",10,"e") == False61 assert python1.ten("HEY",2,"e") == True...
ch7_course.py
Source:ch7_course.py
1class TrainingCourse:23 def __init__(self, title, duration=3, pricePerPerson=150):4 self.title = title5 self.duration = duration6 self.pricePerPerson = pricePerPerson7 self.delegates = []89 def assign_delegate(self, name):10 self.delegates.append(name)1112 def getTotalRevenue(self):13 return self.pricePerPerson * len(self.delegates)1415python1 = TrainingCourse('Python Programming 1', pricePerPerson=100)1617print(f'\nTitle: {python1.title} - Price Per Person: {python1.pricePerPerson} - Duration(days): {python1.duration}\n')1819python1.assign_delegate('Dave')20python1.assign_delegate('Sarah')21python1.assign_delegate('Tim')22
...
Looking for an in-depth tutorial around pytest? LambdaTest covers the detailed pytest tutorial that has everything related to the pytest, from setting up the pytest framework to automation testing. Delve deeper into pytest testing by exploring advanced use cases like parallel testing, pytest fixtures, parameterization, executing multiple test cases from a single file, and more.
Skim our below pytest tutorial playlist to get started with automation testing using the pytest framework.
https://www.youtube.com/playlist?list=PLZMWkkQEwOPlcGgDmHl8KkXKeLF83XlrP
Get 100 minutes of automation test minutes FREE!!