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

AttributeError: 'str' object has no attribute 'reprcrash' while using pytest.mark.xfail #239

Closed
metheuspsc opened this issue Oct 18, 2023 · 4 comments

Comments

@metheuspsc
Copy link
Contributor

metheuspsc commented Oct 18, 2023

Hello!

In my project, I use @pytest.mark.flaky(reruns=3, rerun_except=CustomException) using a specific custom Exception on a couple of tests. That causes the following error that looks similar to issue #175:

INTERNALERROR> E File "/Users/matheuspessoa/PycharmProjects/bigcommerce-adapter/venv/lib/python3.10/site-packages/pytest_rerunfailures.py", line 331, in _matches_any_rerun_except_error
INTERNALERROR> E if re.search(rerun_regex, report.longrepr.reprcrash.message):
INTERNALERROR> E AttributeError: 'str' object has no attribute 'reprcrash'
INTERNALERROR> E assert False

So I suggest the same fix, which I tested locally and worked.

   for rerun_regex in rerun_except_errors:
       try:
           if re.search(rerun_regex, report.longrepr.reprcrash.message):
               return True
       except AttributeError:
           if re.search(rerun_regex, report.longreprtext):
               return True
   return False```python

@danylokholodov
Copy link

@metheuspsc Thank you for your solution! It helped.

@icemac
Copy link
Contributor

icemac commented Oct 20, 2023

@metheuspsc Could you please create a pull request for your fix?

metheuspsc added a commit to metheuspsc/pytest-rerunfailures that referenced this issue Oct 20, 2023
@metheuspsc
Copy link
Contributor Author

@metheuspsc Could you please create a pull request for your fix?

Done

metheuspsc added a commit to metheuspsc/pytest-rerunfailures that referenced this issue Nov 14, 2023
metheuspsc added a commit to metheuspsc/pytest-rerunfailures that referenced this issue Nov 21, 2023
icemac pushed a commit that referenced this issue Nov 22, 2023
@icemac
Copy link
Contributor

icemac commented Nov 22, 2023

Fixed by #240.

@icemac icemac closed this as completed Nov 22, 2023
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

No branches or pull requests

3 participants