Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4353041
Initial commmit adding asyncio mock support.
lisroach May 14, 2018
b83e5a5
Adding async support to the mock library.
lisroach Jul 22, 2018
a9ea983
Removes superfluous changes.
lisroach Aug 16, 2018
50581e3
Cleans up comments.
lisroach Aug 16, 2018
96ddb0e
Fixes inspect and attribute error issues.
lisroach Sep 10, 2018
a4d4dbc
Fixes test_unittest changing env because of version issue.
lisroach Sep 11, 2018
bfdd5a7
Removes newlines from inspect.
lisroach Sep 12, 2018
ed7f13c
Removes unneeded comment and newlines.
lisroach Sep 12, 2018
34fa74e
Fixes async tests. Removes inspect fix.
lisroach Sep 14, 2018
302ef64
Fixes environment test issue.
lisroach Sep 14, 2018
bf749ac
Adds argument tests.
lisroach Sep 14, 2018
30b64b5
Adding the side_effect exception test.
lisroach Sep 14, 2018
5edac2a
Changes CoroutineMock to AsyncMock. Removes old-style coroutine refer…
lisroach May 7, 2019
fa978cc
Merge branch 'master' into asyncio_mock
lisroach May 7, 2019
24920a6
Changes fnmatch to list comp.
lisroach May 7, 2019
aec3153
Fixes import and a rebase.
lisroach May 7, 2019
45dddb7
Merge branch 'master' of https://github.com/python/cpython into async…
lisroach May 7, 2019
c0a88a9
Updates news with AsyncMock name change.
lisroach May 7, 2019
f9bee6e
Removes extraneous comments.
lisroach May 7, 2019
81ad0d1
Fixes RunTime warnings and missing io import.
lisroach May 8, 2019
c260104
Changes check to use issubclass instead of !=.
lisroach May 8, 2019
ae13db1
Adds AsyncMock docs and tests for iterators and context managers.
lisroach May 13, 2019
68dff1b
Uncomments commented out test.
lisroach May 13, 2019
64301e2
Fixes based on comments.
lisroach May 17, 2019
c7cd95e
Fixes broken docs.
lisroach May 17, 2019
033f7d3
Fixes broken doc await_arg.
lisroach May 18, 2019
2fef02c
Adds shoutout to Martin Richard for asynctest.
lisroach May 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removes superfluous changes.
  • Loading branch information
lisroach committed Sep 12, 2018
commit a9ea983a3997a465183008b01d3f7027db6dbc19
24 changes: 13 additions & 11 deletions Lib/unittest/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def __init__(self):

def __getattr__(self, name):
if name == '__bases__':
# Without this help() raises an exception
# Without this help(unittest.mock) raises an exception
raise AttributeError
return self._sentinels.setdefault(name, _SentinelObject(name))

Expand Down Expand Up @@ -465,15 +465,15 @@ def _mock_add_spec(self, spec, spec_set, _spec_as_instance=False,
_spec_coroutines.append(attr)

if spec is not None and not _is_list(spec):
if isinstance(spec, type):
_spec_class = spec
else:
_spec_class = _get_class(spec)
res = _get_signature_object(spec,
_spec_as_instance, _eat_self)
_spec_signature = res and res[1]
if isinstance(spec, type):
_spec_class = spec
else:
_spec_class = _get_class(spec)
res = _get_signature_object(spec,
_spec_as_instance, _eat_self)
_spec_signature = res and res[1]

spec = dir(spec)
spec = dir(spec)

__dict__ = self.__dict__
__dict__['_spec_class'] = _spec_class
Expand Down Expand Up @@ -913,8 +913,7 @@ def _get_child_mock(self, **kw):
child mocks are made.

For non-callable mocks the callable variant will be used (rather than
any custom subclass).
"""
any custom subclass)."""
_new_name = kw.get("_new_name")
if _new_name in self.__dict__['_spec_coroutines']:
return CoroutineMock(**kw)
Expand Down Expand Up @@ -1149,6 +1148,7 @@ def _mock_call(_mock_self, *args, **kwargs):
return ret_val



class Mock(CallableMixin, NonCallableMock):
"""
Create a new `Mock` object. `Mock` takes several optional arguments
Expand Down Expand Up @@ -2004,6 +2004,7 @@ def _mock_set_magics(self):
setattr(_type, entry, MagicProxy(entry, self))



class NonCallableMagicMock(MagicMixin, NonCallableMock):
"""A version of `MagicMock` that isn't callable."""
def mock_add_spec(self, spec, spec_set=False):
Expand All @@ -2016,6 +2017,7 @@ def mock_add_spec(self, spec, spec_set=False):
self._mock_set_magics()



class MagicMock(MagicMixin, Mock):
"""
MagicMock is a subclass of Mock with default implementations
Expand Down