Repository navigation
[18.0][FIX] base_exception: make the swallow test helper run the test - #3793
Open
SparkDrago05 wants to merge 1 commit into
Open
SparkDrago05 wants to merge 1 commit into
SparkDrago05 wants to merge 1 commit into
Conversation
swallow_base_exception_error returned its inner wrapper without calling it, so every test it decorated passed without running its body. - Call the test inside the helper, so tests in other modules that use it run again. - Add expect_base_exception_error, which checks that BaseExceptionError is raised without the savepoint rollback of assertRaises, so the exceptions stored by the detection can still be checked. - Rewrite the six decorated base_exception tests with it. Their bodies now run to the end. Since the rollback change, a detected exception raises BaseExceptionError instead of ValidationError, so their expectations are updated. Fixes OCA#3784 Signed-off-by: SparkDrago05 <huzaifa.farooq05@gmail.com>
Contributor
|
Hi @sebastienbeau, @hparfr, |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3784.
swallow_base_exception_errorreturned its innerwrapperwithout calling it, so every test it decorated passed without running its body.Changes
swallow_base_exception_errornow calls the test. The decorated tests in other modules run again.expect_base_exception_errorcontext manager. It checks thatBaseExceptionErroris raised, but without the savepoint rollback ofassertRaises, so the exceptions stored by the detection can still be checked afterwards.base_exceptiontests that used the swallow helper now use it, and their bodies run to the end.When the helper is only fixed, each of those six tests stops at its first
BaseExceptionError. I instrumented it to confirm: all six stopped at the first confirm or detect call, so none of their later assertions ever ran.Since #3590, a newly detected exception raises
BaseExceptionErrorbefore_check_exception()can raiseValidationError. The oldassertRaises(ValidationError)expectations therefore never matched what the code does today. Nobody noticed because the tests didn't run. They now expectBaseExceptionError, and the remaining checks (exception_ids,exceptions_summary, ignoring, blocking, state after ignoring) all run and pass.Tested
On Odoo 18.0 (official image):
base_exception:0 failed, 0 error(s) of 14 tests.sale_exception(sale-workflow 18.0, a downstream user of the helper) with this branch:0 failed, 0 error(s) of 8 tests.ruff and pylint-odoo (mandatory) are clean.
cc @gal-adhoc