Best Python code snippet using tempest_python
test_app.py
Source:test_app.py
...4from app.config import Config5app = create_app(Config())6client = TestClient(app)7# INDEX8def test_index_no_params():9 response = client.get("/index")10 assert response.status_code == 20011 assert response.json() == {"index": 132.97} # may 202012def test_index_1996():13 response = client.get("/index?year=1996")14 assert response.status_code == 20015 assert response.json() == {"index": 151.28} # may 202016def test_index_2013():17 response = client.get("/index?year=2013")18 assert response.status_code == 20019 assert response.json() == {"index": 110.10} # may 202020def test_index_2020():21 response = client.get("/index?year=2020")22 assert response.status_code == 400...
index.py
Source:index.py
...23 for i in range(len(num_split)):24 sum += int(num_split[i])25 return str(sum)26class index(unittest.TestCase):27 def test_index_no_params(self):28 self.assertEqual(Add(""), "0")29 30 def test_index_one_param(self):31 self.assertEqual(Add("9"), "9")32 def test_index_two_params(self):33 self.assertEqual(Add("9, 10"), "19")34 def test_index_n_params(self):35 self.assertEqual(Add("40, 10, 20, 30, 50"), "150")36 def test_index_n_params_diff_delimeters(self):37 self.assertEqual(Add("40\n10,20,30,50"), "150")38 def test_index_delimeters_and_nums(self):39 self.assertEqual(Add("//;\n1;2"), "3")40 def test_index_with_negative(self):41 self.assertEqual(Add("40\n10,20,-30,50"), "negatives not allowed")...
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!!