Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document all the different ways we can interact with reference container objects like dict, set, list #118

Open
rohitsanj opened this issue May 22, 2021 · 0 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers sprint-friendly A good issue for sprint events

Comments

@rohitsanj
Copy link
Member

We've implemented a bunch of container methods which help us do the following with reference objects:

Internal method Description
__len__ Find length of a container type object (dict, set, list)
__iter__ and __next__ Iterate through an container
__getitem__ Fetch an item by index (or key) from a container
__setitem__ Set an item's value in a container
__contains__ Find if a container... contains an item

It would be nice to have examples that show that users can directly interact with reference objects, for example:

An example for finding length would look like:

from testbook import testbook

@testbook('notebook.ipynb', execute=True)
def test_foo(tb):
    my_list = tb.ref('my_list')
    assert len(my_list) == 3 # this internally calls __len__
@rohitsanj rohitsanj added documentation Improvements or additions to documentation good first issue Good for newcomers sprint-friendly A good issue for sprint events labels May 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers sprint-friendly A good issue for sprint events
Projects
None yet
Development

No branches or pull requests

1 participant