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

Inject mocks #45

Merged
merged 7 commits into from
Jul 20, 2020
Merged

Inject mocks #45

merged 7 commits into from
Jul 20, 2020

Conversation

rohitsanj
Copy link
Member

@rohitsanj rohitsanj commented Jul 19, 2020

Implemented patch contextmanager.

  • Sample usage of patch:
def test_patch_basic(tb):
    func = tb.ref("func")
    with tb.patch("os.listdir", return_value=['file1', 'file2']) as mock_listdir:
        assert func() == ['file1', 'file2']
        mock_listdir.assert_called_once()
  • Sample usage of patch_dict - equivalent to patch.dict of mock library
def test_patch_dict(self, tb):
    with tb.patch_dict("os.environ", {"PATH": "/usr/bin"}, clear=True):
        assert tb.ref("os.environ") == {"PATH": "/usr/bin"} 

Resolves #8

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

Review Jupyter notebook visual diffs & provide feedback on notebooks.


Powered by ReviewNB

@codecov-commenter
Copy link

codecov-commenter commented Jul 19, 2020

Codecov Report

Merging #45 into master will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master       #45   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          269       284   +15     
=========================================
+ Hits           269       284   +15     

@rohitsanj rohitsanj requested a review from MSeal July 19, 2020 18:14
@MSeal MSeal merged commit 9405819 into nteract:master Jul 20, 2020
@rohitsanj rohitsanj mentioned this pull request Aug 6, 2020
3 tasks
@rohitsanj rohitsanj added this to the 0.2.0 milestone Aug 6, 2020
@rohitsanj rohitsanj added the GSoC-2020 Part of Google Summer of Code 2020 label Aug 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GSoC-2020 Part of Google Summer of Code 2020
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Injected mocks
3 participants