Esempio n. 1
0
 def items(self):
     """
     Returns
     -------
     ItemsView
         A view of the keys and objects in the group.
     """
     return abc.ItemsView(self)
Esempio n. 2
0
 def items(self):
     """
     Returns
     -------
     ItemsView
         A view of the keys and objects in the group.
     """
     assert_file_open(self.file)
     return abc.ItemsView(self)
Esempio n. 3
0
    def items(self):
        # type: () -> ItemsView[KT, VT]
        """
        Get items.

        :return: Items.
        :rtype: collections.abc.ItemsView
        """
        return collections_abc.ItemsView(self)
Esempio n. 4
0
def for_various_result_types_of__filter_by_which(test_meth):

    # Taking into consideration that the data specification's
    # overridable method `filter_by_which()` is required to return a
    # container that is either a *dict items view* or a *set-like*
    # object, we want to ensure that the methods which call
    # `filter_by_which()` handle the call results properly for various
    # types of these results (i.e., regardless of whether the result is
    # a *dict items view* or a *set-like* object; regardless of whether
    # the object is an instance of a builtin type or of a custom one;
    # and regardless of whether the object is mutable or immutable...).
    #
    # By wrapping with this decorator a test of a data specification's
    # method which uses `filter_by_which()` call results *and* by
    # decorating the test case class that contains such a test with
    # `@unittest_expander.expand` -- we ensure that the method will be
    # tested for various kinds of types of `filter_by_which()` call
    # results.

    @foreach([
        None,
        lambda iterable: dict(iterable).items(),
        lambda iterable: collections_abc.ItemsView(dict(iterable)),
        frozenset,
        set,
        CustomImmutableSet,
        CustomMutableSet,
    ])
    @functools.wraps(test_meth)
    def decorated_test_meth(self, result_type_adjuster):
        if result_type_adjuster is None:
            test_meth(self)
            return
        called = []
        wrapped = _make_wrapped__filter_by_which(
            result_type_adjuster,
            called,
            orig=self.base_data_spec_class.filter_by_which)
        with patch.object(self.base_data_spec_class, 'filter_by_which',
                          wrapped):
            assert not called, 'bug in the test'
            test_meth(self)
            assert called, 'bug in the test'

    def _make_wrapped__filter_by_which(result_type_adjuster, called, orig):
        @staticmethod
        def wrapped(*args, **kwargs):
            called.append(None)
            orig_result = orig(*args, **kwargs)
            return result_type_adjuster(orig_result)

        return wrapped

    return decorated_test_meth
Esempio n. 5
0
 def items(self):
     return abc.ItemsView(self)
Esempio n. 6
0
 def items(self):
     """D.items() => a set-like object providing a view on D's items"""
     return stdlib_collections.ItemsView(self)