Best Python code snippet using lemoncheesecake
metadatapolicy.py
Source:metadatapolicy.py  
...40        """41        Disallow unknown properties for tests and suites.42        """43        self._disallow_unknown_properties = True44    def add_tag_rule(self, tag_name, on_test=None, on_suite=None):45        """46        Declare a tag rule.47        :param tag_name: the tag name48        :param on_test: whether or not the tag can be used on a test49        :param on_suite: whether or not the tag can be used on a suite50        If neither on_test or on_suite argument are set, then the tag is only available for tests.51        """52        tag_names = tag_name if type(tag_name) in (list, tuple) else [tag_name]53        for tag_name in tag_names:54            on_test, on_suite = self._get_rule_application(on_test, on_suite)55            self._tags[tag_name] = {56                "on_test": on_test,57                "on_suite": on_suite58            }...test_metadata_policy.py
Source:test_metadata_policy.py  
...62    suite = load_suite_from_class(MySuite)63    # passing case64    policy = MetadataPolicy()65    policy.add_property_rule("foo", on_test=True, on_suite=True)66    policy.add_tag_rule(["tag1", "tag2"], on_test=True, on_suite=True)67    policy.disallow_unknown_properties()68    policy.disallow_unknown_tags()69    policy.check_test_compliance(suite.get_tests()[0])70    policy.check_suite_compliance(suite)71    # non-passing case72    policy = MetadataPolicy()73    policy.add_property_rule("bar", on_test=True, on_suite=True)74    policy.add_tag_rule(["tag3"], on_test=True, on_suite=True)75    policy.disallow_unknown_properties()76    policy.disallow_unknown_tags()77    with pytest.raises(MetadataPolicyViolation):78        policy.check_test_compliance(suite.get_tests()[0])79    with pytest.raises(MetadataPolicyViolation):80        policy.check_suite_compliance(suite)81def test_different_test_and_suite_property_configurations():82    @lcc.prop("foo", "1")83    @lcc.suite("MySuite")84    class MySuite:85        @lcc.prop("bar", "2")86        @lcc.test("Some test")87        def sometest(self):88            pass89    suite = load_suite_from_class(MySuite)90    # passing case91    policy = MetadataPolicy()92    policy.add_property_rule("foo", on_suite=True)93    policy.add_property_rule("bar", on_test=True)94    policy.check_test_compliance(suite.get_tests()[0])95    policy.check_suite_compliance(suite)96    # non-passing case97    policy = MetadataPolicy()98    policy.add_property_rule("foo", on_test=True)99    policy.add_property_rule("bar", on_suite=True)100    with pytest.raises(MetadataPolicyViolation):101        policy.check_test_compliance(suite.get_tests()[0])102    with pytest.raises(MetadataPolicyViolation):103        policy.check_suite_compliance(suite)104def test_different_test_and_suite_tag_configurations():105    @lcc.tags("tag1")106    @lcc.suite("MySuite")107    class MySuite:108        @lcc.tags("tag2")109        @lcc.test("Some test")110        def sometest(self):111            pass112    suite = load_suite_from_class(MySuite)113    # passing case114    policy = MetadataPolicy()115    policy.add_tag_rule("tag1", on_suite=True)116    policy.add_tag_rule("tag2", on_test=True)117    policy.check_test_compliance(suite.get_tests()[0])118    policy.check_suite_compliance(suite)119    # non-passing case120    policy = MetadataPolicy()121    policy.add_tag_rule("tag1", on_test=True)122    policy.add_tag_rule("tag2", on_suite=True)123    with pytest.raises(MetadataPolicyViolation):124        policy.check_test_compliance(suite.get_tests()[0])125    with pytest.raises(MetadataPolicyViolation):126        policy.check_suite_compliance(suite)127def test_disallow_unknown_property():128    @lcc.prop("foo", "1")129    @lcc.suite("MySuite")130    class MySuite:131        @lcc.prop("bar", "2")132        @lcc.test("Some test")133        def sometest(self):134            pass135    suite = load_suite_from_class(MySuite)136    # passing case...itch.py
Source:itch.py  
...54        command = [self.bin, "push", file, channel]55        if "user_version" in kwargs:56            command += ["--userversion", kwargs["user_version"]]57        return proc.check_call(command)58    def add_tag_rule(self, name: str, platform: ButlerPlatformType):59        """Create a new rule for the project's channel tags.60        Arguments:61            name (str): The rule that will determine what platform to store it under.62            platform (ButlerPlatformType): The platform for that rule.63        """...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!!
