diff --git a/tests/test_users.py b/tests/test_users.py index 1e85384..74a1eca 100644 --- a/tests/test_users.py +++ b/tests/test_users.py @@ -62,6 +62,9 @@ def test_user_list(): instancetypes = (Movie, TVShow, TVSeason, TVEpisode, Person) assert all([isinstance(k, instancetypes) for k in l]) + # len() agrees with what iteration yields + assert len(l) == len(list(l)) + # PUT to add and remove items from list l.add_items() for k, v in data.items(): diff --git a/trakt/users.py b/trakt/users.py index 1a4c6ed..5c728f6 100644 --- a/trakt/users.py +++ b/trakt/users.py @@ -214,6 +214,10 @@ def __iter__(self): """Iterate over the items in this user list""" return self._items.__iter__() + def __len__(self): + """Return the number of items in this user list""" + return len(self._items) + @classmethod @post def create(cls, name, creator, description=None, privacy='private',