Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pytest-odoo #1262

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from
Open

Conversation

petrus-v
Copy link

@petrus-v petrus-v commented Oct 19, 2024

uptstream PR: odoo#184409

Description of the issue/feature this PR addresses:

Allow other python test launcher than unittest back (this was introduced by this commit odoo@ccf3c1e) in odoo 18 only.

wasSuccessful function is injected by unitest launcher and not present while using pytest launcher (using pytest-odoo plugin)

Current behavior before PR:

Tests failed with following error using pytest

    def run(self, result):
        testMethod = getattr(self, self._testMethodName)
    
        if getattr(testMethod, '_retry', True) and getattr(self, '_retry', True):
            tests_run_count = self._tests_run_count
        else:
            tests_run_count = 1
            _logger.info('Auto retry disabled for %s', self)
    
        quiet_log = None
        for retry in range(tests_run_count):
            result.had_failure = False  # reset in case of retry without soft_fail
            if retry:
                _logger.runbot(f'Retrying a failed test: {self}')
            if retry < tests_run_count-1:
                with warnings.catch_warnings(), \
                        result.soft_fail(), \
                        lower_logging(25, logging.INFO) as quiet_log:
                    super().run(result)
                if not (result.had_failure or quiet_log.had_error_log):
                    break
            else:  # last try
                super().run(result)
>               if not result.wasSuccessful() and BaseCase._tests_run_count != 1:
E               AttributeError: 'TestCaseFunction' object has no attribute 'wasSuccessful'

.venv/lib/python3.12/site-packages/odoo/tests/common.py:339: AttributeError

Desired behavior after PR is merged:

no errors raised from tests/common.py


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

wasSuccessful function is injected by unitest launcher and
not present while using pytest launcher (using pytest-odoo plugin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant