Best Python code snippet using Airtest
test_screen_proxy.py
Source:test_screen_proxy.py
...47 self.assertIsInstance(obj, ScreenProxy)48 self.assertIsInstance(obj.snapshot(), ndarray)49 def test_cap_method(self):50 self.assertIn(self.dev.cap_method, ScreenProxy.SCREEN_METHODS.keys())51 def test_set_projection(self):52 # ç®åææ¶åªæ¯æminicap设置projectionåæ°53 if self.dev.cap_method == "MINICAP":54 self.dev.keyevent("HOME")55 default_height = 80056 height = self.dev.display_info.get("height")57 width = self.dev.display_info.get("width")58 scale_factor = min(default_height, height) / height59 projection = (scale_factor * width, scale_factor * height)60 screen = string_2_img(self.dev.screen_proxy.get_frame(projection=projection))61 self.assertEqual(screen.shape[0], default_height)62 def test_custom_cap_method(self):63 """64 Test adding a custom screenshot method65 æµè¯æ·»å ä¸ä¸ªèªå®ä¹çæªå¾æ¹æ³...
test.py
Source:test.py
...46 except FileNotFoundError:47 pass48 a = RasterData.create(img_path, 10, 10, 1, 0, 0)49 assert isinstance(a, RasterData)50def test_set_projection():51 img_path = os.path.abspath("tests/data/test_image.tif")52 try:53 os.remove(img_path)54 except FileNotFoundError:55 pass56 source_raster = RasterData.create(img_path, 10, 10, 1, 0, 0)57 source_raster.set_srs(4326)58 srs = create_osr_srs(source_raster.proj)59 assert srs.GetAttrValue("AUTHORITY", 1) == '4326'60def test_read_all():61 source_raster = RasterData("tests/data/imagem.tiff")62 array = source_raster.read_all()63 assert array.shape == (3, 400, 400)64if __name__ == '__main__':65 test_clone()66 # test_read_all()67 # test_set_projection()...
test_flat_grid_2d.py
Source:test_flat_grid_2d.py
...27def test_get_coordinate_instance_for():28 g = FlatGrid2D()29 for ctype in ['equatorial', 'horizontal', 'spherical']:30 assert isinstance(g.get_coordinate_instance_for(ctype), Coordinate2D)31def test_set_projection():32 g = FlatGrid2D()33 p = g.projection.copy()34 p.reference = Coordinate2D([1, 1])35 assert p != g.projection36 g.set_projection(p)37 assert g.projection == p38 with pytest.raises(ValueError) as err:39 g.set_projection(None)40 assert "Generic projections are not allowed" in str(err.value)41def test_parse_projection():42 g = FlatGrid2D()43 h = fits.Header()44 h['CDELT1'] = 2.045 h['CDELT2'] = 3.0...
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!!