kunit: tool: use `with open()` in unit test
authorDaniel Latypov <dlatypov@google.com>
Wed, 2 Dec 2020 19:08:23 +0000 (11:08 -0800)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 8 Feb 2021 22:35:57 +0000 (15:35 -0700)
commita3ece0795b9ab234ff196e74606fdef9f463ec5a
treed6c36126a89f39af4184134c82b5afdfc3926a54
parent0b3e68076bb9a8e1b1bd448994b9c57828173d8e
kunit: tool: use `with open()` in unit test

The use of manual open() and .close() calls seems to be an attempt to
keep the contents in scope.
But Python doesn't restrict variables like that, so we can introduce new
variables inside of a `with` and use them outside.

Do so to make the code more Pythonic.

Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Tested-by: Brendan Higgins <brendanhiggins@google.com>
Acked-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/kunit/kunit_tool_test.py