forked from avocado-framework/avocado
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests/unit/utils/cpu.py: support the context manager pattern
The current mock method on the two tests modified here do not support the context manager pattern. Let's use the standard library support for mocking open that supports it. This is needed for future lint check improvements that will enforce the use of open() as a context manager to avoid leaking resources. The test_set_idle_state_withsetstate() test has a significant change of behavior: one io.BytesIO instance was used for the writes that, in real life, would happen on two different files. The proposed change brings a more realistic, with a single write to a single file (although it only checks half of the values now). Still, I believe this is an improvement, including the extra check for the file that was actually written to. Reference: https://docs.python.org/3/library/unittest.mock.html#mock-open Signed-off-by: Cleber Rosa <[email protected]>
- Loading branch information
Showing
1 changed file
with
27 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters