Ejemplo n.º 1
0
    def test_callable_attribute(self):
        """Callable attributes are called and any False causes the match to fail"""
        self.assertTrue(attrmatch({'att': 10}, att=lambda val: True))
        self.assertFalse(attrmatch({'att': 10}, att=lambda val: False))

        def even(val):
            return val % 2 == 0
        self.assertTrue(attrmatch({'att': 10}, att=even))
        self.assertFalse(attrmatch({'att': 11}, att=even))
    def test_callable_attribute(self):
        """Callable attributes are called and any False causes the match to fail"""
        self.assertTrue(attrmatch({'att': 10}, att=lambda val: True))
        self.assertFalse(attrmatch({'att': 10}, att=lambda val: False))

        def even(val):
            return val % 2 == 0
        self.assertTrue(attrmatch({'att': 10}, att=even))
        self.assertFalse(attrmatch({'att': 11}, att=even))
Ejemplo n.º 3
0
 def filter(task):
     # NOTE: on the ash branch, update taskcluster/ci/desktop-test/tests.yml to
     # run the M-dt-e10s tasks
     attrs = t.attributes
     if attrs.get('kind') not in BUILD_AND_TEST_KINDS:
         return False
     if not attrmatch(attrs, build_platform=set([
         'linux64',
         'linux64-asan',
         'linux64-pgo',
     ])):
         return False
     if not attrmatch(attrs, e10s=True):
         return False
     return True
 def test_all_matches_required(self):
     """If only one attribute does not match, the result is False"""
     self.assertFalse(attrmatch({"a": 1}, a=1, b=2, c=3))
     self.assertFalse(attrmatch({"a": 1, "b": 2}, a=1, b=2, c=3))
     self.assertTrue(attrmatch({"a": 1, "b": 2, "c": 3}, a=1, b=2, c=3))
 def test_set_attribute(self):
     """Set attributes require set membership"""
     self.assertTrue(attrmatch({"att": 10}, att=set([9, 10])))
     self.assertFalse(attrmatch({"att": 10}, att=set([19, 20])))
 def test_literal_attribute(self):
     """Literal attributes must match exactly"""
     self.assertTrue(attrmatch({"att": 10}, att=10))
     self.assertFalse(attrmatch({"att": 10}, att=20))
 def test_missing_attribute(self):
     """If a filtering attribute is not present, no match"""
     self.assertFalse(attrmatch({}, someattr=10))
 def test_trivial_match(self):
     """Given no conditions, anything matches"""
     self.assertTrue(attrmatch({}))
 def test_all_matches_required(self):
     """If only one attribute does not match, the result is False"""
     self.assertFalse(attrmatch({'a': 1}, a=1, b=2, c=3))
     self.assertFalse(attrmatch({'a': 1, 'b': 2}, a=1, b=2, c=3))
     self.assertTrue(attrmatch({'a': 1, 'b': 2, 'c': 3}, a=1, b=2, c=3))
Ejemplo n.º 10
0
 def test_set_attribute(self):
     """Set attributes require set membership"""
     self.assertTrue(attrmatch({'att': 10}, att=set([9, 10])))
     self.assertFalse(attrmatch({'att': 10}, att=set([19, 20])))
Ejemplo n.º 11
0
 def test_literal_attribute(self):
     """Literal attributes must match exactly"""
     self.assertTrue(attrmatch({'att': 10}, att=10))
     self.assertFalse(attrmatch({'att': 10}, att=20))
Ejemplo n.º 12
0
 def test_missing_attribute(self):
     """If a filtering attribute is not present, no match"""
     self.assertFalse(attrmatch({}, someattr=10))
Ejemplo n.º 13
0
 def test_trivial_match(self):
     """Given no conditions, anything matches"""
     self.assertTrue(attrmatch({}))