def test_matches_with_range(self):
        source = [
            MagicMock(foo=1),
            MagicMock(foo=3),
        ]

        results = utils.matches(*source, foo__range=(1, 2))
        assert source[0] in results
        assert source[1] not in results
Esempio n. 2
0
    def test_matches_with_range(self):
        source = [
            MagicMock(foo=1),
            MagicMock(foo=3),
        ]

        results = utils.matches(*source, foo__range=(1, 2))
        assert source[0] in results
        assert source[1] not in results
    def test_matches_excludes_object_from_results_when_not_match(self, get_attr_mock):
        source = [
            MagicMock(foo=1),
            MagicMock(foo=2),
        ]

        get_attr_mock.return_value = None, None
        results = utils.matches(*source, foo__gt=5)

        for x in source:
            assert x not in results
Esempio n. 4
0
    def test_matches_excludes_object_from_results_when_not_match(self, get_attr_mock):
        source = [
            MagicMock(foo=1),
            MagicMock(foo=2),
        ]

        get_attr_mock.return_value = None, None
        results = utils.matches(*source, foo__gt=5)

        for x in source:
            assert x not in results