diff options
author | boon <ohbooneng@google.com> | 2023-04-26 02:10:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-25 11:10:03 -0700 |
commit | 791b49cbe68057c9d397430a6d76f8f4fc21465e (patch) | |
tree | ec830e7bc342701464ae9b7d709a8dd88fa08496 /tests/mobly/base_test_test.py | |
parent | 8693d1812c7cb3b3c19933970a55c1babb1bf78a (diff) | |
download | mobly-791b49cbe68057c9d397430a6d76f8f4fc21465e.tar.gz |
Properly end the test when expects has an error within teardown test. (#882)
Diffstat (limited to 'tests/mobly/base_test_test.py')
-rwxr-xr-x | tests/mobly/base_test_test.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/mobly/base_test_test.py b/tests/mobly/base_test_test.py index be67437..b166357 100755 --- a/tests/mobly/base_test_test.py +++ b/tests/mobly/base_test_test.py @@ -510,6 +510,28 @@ class BaseTestTest(unittest.TestCase): "Requested 1, Skipped 0") self.assertEqual(bt_cls.results.summary_str(), expected_summary) + def test_teardown_test_expects_error(self): + + class MockBaseTest(base_test.BaseTestClass): + + def teardown_test(self): + expects.expect_true(False, MSG_EXPECTED_EXCEPTION) + + def test_something(self): + pass + + bt_cls = MockBaseTest(self.mock_test_cls_configs) + bt_cls.run() + actual_record = bt_cls.results.error[0] + self.assertEqual(actual_record.test_name, self.mock_test_name) + self.assertEqual(actual_record.details, MSG_EXPECTED_EXCEPTION) + self.assertIsNone(actual_record.extras) + self.assertFalse(actual_record.extra_errors) + self.assertTrue(actual_record.end_time) + expected_summary = ("Error 1, Executed 1, Failed 0, Passed 0, " + "Requested 1, Skipped 0") + self.assertEqual(bt_cls.results.summary_str(), expected_summary) + def test_teardown_test_executed_if_test_pass(self): my_mock = mock.MagicMock() |