MCPcopy Create free account
hub / github.com/EasyIME/PIME / mockable

Method mockable

python/python3/tornado/options.py:481–496  ·  view source on GitHub ↗

Returns a wrapper around self that is compatible with `mock.patch `. The `mock.patch ` function (included in the standard library `unittest.mock` package since Python 3.3, or in the third-party ``mock`` package for older vers

(self)

Source from the content-addressed store, hash-verified

479 callback()
480
481 def mockable(self) -> "_Mockable":
482 """Returns a wrapper around self that is compatible with
483 `mock.patch <unittest.mock.patch>`.
484
485 The `mock.patch <unittest.mock.patch>` function (included in
486 the standard library `unittest.mock` package since Python 3.3,
487 or in the third-party ``mock`` package for older versions of
488 Python) is incompatible with objects like ``options`` that
489 override ``__getattr__`` and ``__setattr__``. This function
490 returns an object that can be used with `mock.patch.object
491 <unittest.mock.patch.object>` to modify option values::
492
493 with mock.patch.object(options.mockable(), 'name', value):
494 assert options.name == value
495 """
496 return _Mockable(self)
497
498
499class _Mockable(object):

Callers 1

test_mock_patchMethod · 0.95

Calls 1

_MockableClass · 0.85

Tested by 1

test_mock_patchMethod · 0.76