Best Python code snippet using lemoncheesecake
metadatapolicy.py
Source:metadatapolicy.py
...60 """61 Disallow unknown tags for tests and suites.62 """63 self._disallow_unknown_tags = True64 def _check_compliance(self, obj, obj_type,65 available_properties, forbidden_properties,66 available_tags, forbidden_tags):67 # check unknown properties68 if self._disallow_unknown_properties:69 for property_name in obj.properties.keys():70 if property_name not in available_properties:71 help_msg = "available are %s" % ", ".join(map(repr, available_properties.keys())) \72 if available_properties else "no property is available"73 raise MetadataPolicyViolation(74 "In %s '%s', the property '%s' is not supported (%s)" % (75 obj_type, obj.path, property_name, help_msg76 )77 )78 # check forbidden properties79 for property_name in obj.properties.keys():80 if property_name in forbidden_properties:81 raise MetadataPolicyViolation(82 "In %s '%s', the property '%s' is not accepted on a %s" % (83 obj_type, obj.path, property_name, obj_type84 )85 )86 # check required properties87 for required_property in filter(lambda p: available_properties[p]["required"], available_properties.keys()):88 if required_property not in obj.properties.keys():89 raise MetadataPolicyViolation(90 "In %s '%s', the mandatory property '%s' is missing" % (91 obj_type, obj.path, required_property92 )93 )94 # check properties allowed values95 for name, value in obj.properties.items():96 if name not in available_properties:97 continue98 if available_properties[name]["values"] and value not in available_properties[name]["values"]:99 raise MetadataPolicyViolation(100 "In %s '%s', value '%s' of property '%s' is not among accepted values: %s" % (101 obj_type, obj.path, value, name, available_properties[name]["values"]102 )103 )104 # check unknown tags105 if self._disallow_unknown_tags:106 for tag in obj.tags:107 if tag not in available_tags.keys():108 help_msg = "available are %s" % ", ".join(map(repr, available_tags.keys())) \109 if available_tags else "no property is available"110 raise MetadataPolicyViolation(111 "In %s '%s', the tag '%s' is not supported (%s)" % (112 obj_type, obj.path, tag, help_msg113 )114 )115 # check forbidden tags116 for tag in obj.tags:117 if tag in forbidden_tags:118 raise MetadataPolicyViolation(119 "In %s '%s', the tag '%s' is not accepted on a %s" % (120 obj_type, obj.path, tag, obj_type121 )122 )123 def check_test_compliance(self, test):124 """125 Check if the test complies to the metadata policy.126 Raise MetadataPolicyViolation if not compliant.127 """128 self._check_compliance(129 test, "test",130 {prop_name: p for prop_name, p in self._properties.items() if p["on_test"]},131 [prop_name for prop_name, p in self._properties.items() if not p["on_test"]],132 {tag_name: t for tag_name, t in self._tags.items() if t["on_test"]},133 [tag_name for tag_name, t in self._tags.items() if not t["on_test"]]134 )135 def check_suite_compliance(self, suite):136 """137 Check if the suite complies to the metadata policy.138 If recursive if set to True (which is the default), then suite tests and sub suites are also checked.139 Raise MetadataPolicyViolation if not compliant.140 """141 self._check_compliance(142 suite, "suite",143 {prop_name: p for prop_name, p in self._properties.items() if p["on_suite"]},144 [prop_name for prop_name, p in self._properties.items() if not p["on_suite"]],145 {tag_name: t for tag_name, t in self._tags.items() if t["on_suite"]},146 [tag_name for tag_name, t in self._tags.items() if not t["on_suite"]]147 )148 for test in suite.get_tests():149 self.check_test_compliance(test)150 def check_suites_compliance(self, suites):151 """152 Check if the suites comply to the metadata policy.153 Raise MetadataPolicyViolation if not compliant.154 """155 for suite in flatten_suites(suites):...
validation_sharpness_din.py
Source:validation_sharpness_din.py
...207 sharpness[i] = S208 # Load reference value209 reference[i] = noise[i]["S"]210 noise_type = noise[0]["type"]211 _check_compliance(sharpness, reference, noise_type)212def _check_compliance(sharpness, reference, noise_type):213 """Check the compliance of sharpness calc. to DIN 45692214 The compliance is assessed according to chapter 6 of the215 standard DIN 45692_2009E.216 One .png compliance plot is generated.217 Parameters218 ----------219 sharpness : numpy.array220 computed sharpness values221 reference : numpy.array222 reference sharpness values223 Outputs224 -------225 tst : bool226 Compliance to the reference data...
test_loudness_zwtv.py
Source:test_loudness_zwtv.py
...44 assert len(N) == len(time_axis)45 assert N_spec.shape[1] == len(time_axis)46 assert N_spec.shape[0] == len(bark_axis)47 # Check ISO 532-1 compliance48 assert _check_compliance(loudness, signal, "./tests/output/")49# test de la fonction50if __name__ == "__main__":...
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!!