Tin mới
unittest — Unit testing framework
unittest.mock — getting started
If an AttributeError is raised by PropertyMock, it will be interpreted as a missing descriptor and __getattr__() will be called on the parent mock:
Mock objects create attributes on demand. This allows them to pretend to be objects of any type.
Mock objects create attributes on demand. This allows them to pretend to be objects of any type.
Patch a dictionary, or dictionary like object, and restore the dictionary to its original state after the test, where the restored dictionary is a copy of the dictionary as it was before the test.
Mock supports mocking the Python protocol methods, also known as “magic methods”. This allows mock objects to replace containers or other objects that implement Python protocols.
Mock supports mocking the Python protocol methods, also known as “magic methods”. This allows mock objects to replace containers or other objects that implement Python protocols.
Changed in version 3.8: Added support for os.PathLike.__fspath__().
copy: Shallow and deep copy operations.
Changed in version 3.7: The sentinel attributes now preserve their identity when they are copied or pickled.
pickle: Convert Python objects to streams of bytes and back.
Changed in version 3.7: The sentinel attributes now preserve their identity when they are copied or pickled.
A helper function to create a mock to replace the use of open(). It works for open() called directly or used as a context manager.