Add mockify.api module for easier importing of most commonly used names
Such imports:
from foo import a, b, c, d, spam, more_spam, foo, bar
are discouraged as they require to import much more behind the scenes to work, effectively making foo
a single Python module - even if split into multiple files. If you then import from foo.bar import Bar
, all other names are implicitly loaded as well. That makes longer import times.
To deal with that it is recommended not to use from foo import ...
, but rather expose multiple child modules + optionally extra one (f.e. api
) that have to be explicitly imported. So example from above is converted into this:
from foo.api import a, b, c, d, spam, more_spam, foo, bar
This task is to make following things:
- deprecate all names imported by root
mockify
module (of coursefrom mockify.core
and others are still valid) - provide
mockify.api
module being a placeholder for most commonly used Mockify functions and classes, so instead of having multiple imports in test files it will be able to import all at once (of course with explicit imports of core functionality, actions etc. still possible)
from mockify.api import satisfied, Mock, Return
def test_foo():
mock = Mock('mock')
mock.expect_call().will_once(Return('spam'))
with satisfied(mock):
assert mock() == 'spam'
Edited by Maciej Wiatrzyk