Best Python code snippet using locust
test_model.py
Source:test_model.py
...204 o = _create_overview()205 o.footprint_geometry = normal_poly206 res: BaseGeometry = benchmark(lambda: o.footprint_wgs84)207 assert_shapes_mostly_equal(res, expected_poly, 0.001)208def test_computed_properties():209 o = _create_overview()210 o.product_name = "test_product"211 def check_flat_period(o, expected_period: str, expected_date: date):212 assert o.as_flat_period() == (expected_period, expected_date)213 # Converting the other way should also match.214 unflattened = TimePeriodOverview.from_flat_period_representation(215 *o.as_flat_period()216 )217 assert (o.year, o.month, o.day) == unflattened218 assert o.label == "test_product all all all"219 check_flat_period(o, "all", date(1900, 1, 1))220 assert str(o) == "test_product all all all (1 dataset)"221 o.year = 2018222 assert o.label == "test_product 2018 all all"...
image.py
Source:image.py
...37 self.assertEqual(im.width, 256)38 self.assertEqual(im.height, 256)39 self.assertEqual(im.crs, self.epsg_4326)40 self.assertTrue(im.vrt.startswith("<VRTDataset "))41 def test_computed_properties(self):42 im = self.fixture()43 self.assertEqual(im.px_width, 2.0/300)44 self.assertEqual(im.px_height, -2.0/200)45 self.assertEqual(im.transform, (-1.0, 2.0/300, 0.0, 1.0, 0.0, -2.0/200))46 self.assertEqual(im.bbox, (-1.0, -1.0, 1.0, 1.0))47 def test_window(self):48 im = self.fixture()49 self.assertEqual(im.window((0.0, 0.0, 1.0, 1.0)), (150, 0, 150, 100))50 def test_predicates(self):51 im = self.fixture()52 # identity53 self.assertEqual(im.intersection(im.bbox), im.bbox)54 # partial intersection55 self.assertEqual(im.intersection((0.0, 0.0, 2.0, 2.0)), (0.0, 0.0, 1.0, 1.0))...
test_course.py
Source:test_course.py
...7 def setUp(self):8 with open('test/courses-fixture.json', 'r') as file:9 data = json.load(file)10 self.courses = [Course(**c) for c in data]11 def test_computed_properties(self):12 # test a course with one instructor and with two13 one_instructor = self.courses[0]14 two_instructors = self.courses[4]15 # instructor methods16 self.assertEqual(one_instructor.instructor_names, 'Donald Fortescue')17 self.assertEqual(one_instructor.instructor_usernames, 'dfortescue')18 self.assertEqual(two_instructors.instructor_names, 'Megan Werner, Elin Christopherson')19 self.assertEqual(two_instructors.instructor_usernames, 'mwerner, echristopherson')20 # test on_portal - one_instructor course is status: Preliminary21 self.assertFalse(one_instructor.on_portal)22 self.assertTrue(two_instructors.on_portal)23 self.assertFalse(next(c for c in self.courses if c.hidden == '1').on_portal)24 self.assertFalse(self.courses[11].on_portal) # EXTED course25 # test a first year course rather than another UDIST one...
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!!