kunit: tool: fix unit test cleanup handling
authorDaniel Latypov <dlatypov@google.com>
Wed, 2 Dec 2020 19:08:21 +0000 (11:08 -0800)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 8 Feb 2021 22:33:32 +0000 (15:33 -0700)
commitcfd607e43da4a20753744f134e201310262b827a
tree6d54478b251218123d18a0cae109e90a6b40f314
parent92bf22614b21a2706f4993b278017e437f7785b3
kunit: tool: fix unit test cleanup handling

* Stop leaking file objects.
* Use self.addCleanup() to ensure we call cleanup functions even if
setUp() fails.
* use mock.patch.stopall instead of more error-prone manual approach

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