mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-28 05:26:13 +02:00
Improve handling of mocking logic in pytest (#1382)
* WIP * fix handling of user input (stdin, input, getpass) * take out redundant pytest step * fix handling of 'we should' statements * fix test that doesn't use a config file * fix another test that uses stdin Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com> * remove .tool-versions file per PR feedback * add comment to clarify why disembodied variables are here Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
parent
3518e37087
commit
2ab485de8c
16 changed files with 259 additions and 197 deletions
|
@ -49,3 +49,24 @@ def get_nested_val(dictionary, path, *default):
|
|||
if default:
|
||||
return default[0]
|
||||
raise
|
||||
|
||||
|
||||
# @see: https://stackoverflow.com/a/41599695/569146
|
||||
def spy_wrapper(wrapped_function):
|
||||
from unittest import mock
|
||||
|
||||
mock = mock.MagicMock()
|
||||
|
||||
def wrapper(self, *args, **kwargs):
|
||||
mock(*args, **kwargs)
|
||||
return wrapped_function(self, *args, **kwargs)
|
||||
|
||||
wrapper.mock = mock
|
||||
return wrapper
|
||||
|
||||
|
||||
def get_fixture(request, name, default=None):
|
||||
result = default
|
||||
if name in request.node.fixturenames:
|
||||
result = request.getfixturevalue(name)
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue