Best Python code snippet using tavern
test_mesh.py
Source:test_mesh.py
...50 """51 FirstMesh(0, 100)52 @staticmethod53 @raises(ValueError)54 def test_invalid_code():55 """Invalid mesh code causes a ValueError.56 """57 FirstMesh.from_code('53393')58class TestSecondMesh(unittest.TestCase):59 """60 Tests for jpmesh.SecondMesh.61 """62 ORG_CODE = '5339-45'63 CODE = '533945'64 SOUTH_WEST = Coordinate(65 lon=Angle.from_millisecond(502650000.0),66 lat=Angle.from_millisecond(128400000.0))67 def test_from_code(self):68 """Test for jpmesh.coordinate.SecondMesh.from_code.69 """70 _test_from_code(SecondMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)71 def test_from_coordinate(self):72 """Test for jpmesh.coordinate.SecondMesh.from_coordinate.73 """74 _test_from_coordinate(SecondMesh, self.CODE, self.SOUTH_WEST)75 @raises(ValueError)76 def test_invalid_lat_number(self):77 """An invalid latitude number causes a ValueError.78 """79 SecondMesh(self.SOUTH_WEST, 9, 0)80 @raises(ValueError)81 def test_invalid_lon_number(self):82 """An invalid longitude number causes a ValueError.83 """84 SecondMesh(self.SOUTH_WEST, 0, 9)85 @staticmethod86 @raises(ValueError)87 def test_invalid_code():88 """Invalid mesh code causes a ValueError.89 """90 SecondMesh.from_code('5339356')91class TestThirdMesh(unittest.TestCase):92 """Tests for jpmesh.ThirdMesh.93 """94 ORG_CODE = '5339-35-96'95 CODE = '53393596'96 SOUTH_WEST = Coordinate(97 lon=Angle.from_millisecond(502920000.0),98 lat=Angle.from_millisecond(128370000.0))99 def test_from_code(self):100 """101 Test for jpmesh.coordinate.ThirdMesh.from_code.102 """103 _test_from_code(ThirdMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)104 def test_from_coordinate(self):105 """106 Test for jpmesh.coordinate.ThirdMesh.from_coordinate.107 """108 _test_from_coordinate(ThirdMesh, self.CODE, self.SOUTH_WEST)109 @raises(ValueError)110 def test_invalid_lat_number(self):111 """112 An invalid latitude number causes a ValueError.113 """114 ThirdMesh(self.SOUTH_WEST, 10, 0)115 @raises(ValueError)116 def test_invalid_lon_number(self):117 """118 An invalid longitude number causes a ValueError.119 """120 ThirdMesh(self.SOUTH_WEST, 0, 10)121 @staticmethod122 @raises(ValueError)123 def test_invalid_code():124 """125 Invalid mesh code causes a ValueError.126 """127 ThirdMesh.from_code('533935379')128class TestHalfMesh(unittest.TestCase):129 """130 Tests for jpmesh.HalfMesh.131 """132 ORG_CODE = '5339-35-96-4'133 CODE = '533935964'134 SOUTH_WEST = Coordinate(135 lon=Angle.from_millisecond(502942500.0),136 lat=Angle.from_millisecond(128385000.0))137 def test_from_code(self):138 """139 Test for jpmesh.coordinate.HalfMesh.from_code.140 """141 _test_from_code(HalfMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)142 def test_from_coordinate(self):143 """144 Test for jpmesh.coordinate.HalfMesh.from_coordinate.145 """146 _test_from_coordinate(HalfMesh, self.CODE, self.SOUTH_WEST)147 @raises(ValueError)148 def test_invalid_div_index(self):149 """150 An invalid division index causes a ValueError.151 """152 HalfMesh(self.SOUTH_WEST, 5)153 @staticmethod154 @raises(ValueError)155 def test_invalid_code():156 """157 Invalid mesh code causes a ValueError.158 """159 HalfMesh.from_code('53393537')160class TestQuarterMesh(unittest.TestCase):161 """162 Tests for jpmesh.QuarterMesh.163 """164 ORG_CODE = '5339-35-96-1-4'165 CODE = '5339359614'166 SOUTH_WEST = Coordinate(167 lon=Angle.from_millisecond(502931250.0),168 lat=Angle.from_millisecond(128377500.0))169 def test_from_code(self):170 """171 Test for jpmesh.coordinate.QuarterMesh.from_code.172 """173 _test_from_code(QuarterMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)174 def test_from_coordinate(self):175 """176 Test for jpmesh.coordinate.QuarterMesh.from_coordinate.177 """178 _test_from_coordinate(QuarterMesh, self.CODE, self.SOUTH_WEST)179 # Skip the error variations because these are common to HalfMesh.180class TestOneEighthMesh(unittest.TestCase):181 """182 Tests for jpmesh.OneEighthMesh.183 """184 ORG_CODE = '5339-35-96-1-1-4'185 CODE = '53393596114'186 SOUTH_WEST = Coordinate(187 lon=Angle.from_millisecond(502925625.0),188 lat=Angle.from_millisecond(128373750.0))189 def test_from_code(self):190 """191 Test for jpmesh.coordinate.OneEighthMesh.from_code.192 """193 _test_from_code(OneEighthMesh, self.ORG_CODE, self.CODE, self.SOUTH_WEST)194 def test_from_coordinate(self):195 """196 Test for jpmesh.coordinate.OneEighthMesh.from_coordinate.197 """198 _test_from_coordinate(OneEighthMesh, self.CODE, self.SOUTH_WEST)199 # Skip the error variations because these are common to HalfMesh.200class TestParseMeshCode(unittest.TestCase):201 """202 Tests for jpmesh.parse_mesh_code.203 """204 @staticmethod205 def test_validcode():206 """207 Returns correct meshes if valid mesh codes are given.208 """209 ok_(isinstance(parse_mesh_code('5339'), FirstMesh))210 ok_(isinstance(parse_mesh_code('533935'), SecondMesh))211 ok_(isinstance(parse_mesh_code('53393573'), ThirdMesh))212 ok_(isinstance(parse_mesh_code('533935731'), HalfMesh))213 ok_(isinstance(parse_mesh_code('5339357312'), QuarterMesh))214 ok_(isinstance(parse_mesh_code('53393573123'), OneEighthMesh))215 @staticmethod216 @raises(ValueError)217 def test_empty_code():218 """219 Raises ValueError if empty mesh codes are given.220 """221 isinstance(parse_mesh_code(''), FirstMesh)222 @staticmethod223 @raises(ValueError)224 def test_invalid_code():225 """226 Raises ValueError if invalid mesh codes are given.227 """...
test_exceptions.py
Source:test_exceptions.py
...10 def test_exceptions_code(self):11 module = self._get()12 exc_8 = module.EXCEPTIONS[-8]13 self.assertTrue(isinstance(exc_8(), module.BadArgumentsError))14 def test_invalid_code(self):15 module = self._get()...
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!!