Repository navigation
Rerun flaky tests that fail in setup - #148
Conversation
|
Hi @JonathanRRogers, thanks for the pull request. Before we can merge it, we need you to sign our Contributor License Agreement. You can do so electronically here: http://opensource.box.com/cla Once you have signed, just add a comment to this pull request saying, "CLA signed". Thanks! |
|
CLA signed |
|
Verified that @JonathanRRogers has just signed the CLA. Thanks, and we look forward to your contribution. |
|
@boxcla Any chance of getting this merged in? Would be very helpful for our tests. |
|
Guys, can we get this merged? |
|
This PR breaks some of flaky's functionality, so it can't be merged as is. Flaky currently keeps track of how many times a test has passed, and this PR erroneously inflates that number (it counts test setup and test run separately). Will welcome an update that fixes this problem. |
|
So, after more than a year of no feedback from any person at Box, there was finally a comment requesting a change. Before I did anything else, the fact that I already signed the CLA was inexplicably forgotten. I'm starting to wonder if Box really welcomes contributions. |
|
Fair points. It seems the new CLA assistant forgot I signed it, too =/ Apologies for the lack of feedback until now. |
|
@JonathanRRogers would you mind resigning and merging? Thanks! |
|
Sorry about the delay. I think everything's in order now. |
| # Start flaky modifications | ||
| # only retry on call, not setup or teardown | ||
| if report.when == self._PYTEST_WHEN_CALL: | ||
| if report.when in self._PYTEST_WHENS: |
There was a problem hiding this comment.
I think this new condition should only apply to the failure case (not the success case).
So maybe we can rewrite the following few lines like this:
if report.when == self._PYTEST_WHEN_CALL and report.outcome == self._PYTEST_OUTCOME_PASSED:
if self._should_handle_test_success(item):
log = False
elif report.when in self._PYTEST_WHENS and report.outcome == self._PYTEST_OUTCOME_FAILED:
err, name = self._get_test_name_and_err(item, when)
if self._will_handle_test_error_or_failure(item, name, err):
log = False
I think that should still allow rerunning tests that fail in setup, and it won't erroneously count every test success as having passed twice.
There was a problem hiding this comment.
I'm not sure what you mean about counting every test success as having passed twice. Here's output from running one test in which the setup failed once, then passed:
`
[sscadmin@57a98df50c92 ~]$ pytest -v ~/test_a.py
========================================================================== test session starts ===========================================================================
platform linux2 -- Python 2.7.17, pytest-4.6.11, py-1.9.0, pluggy-0.13.1 -- /home/sscadmin/.local/share/virtualenvs/flaky/bin/python2.7
cachedir: .pytest_cache
rootdir: /home/sscadmin
plugins: cov-2.10.0, forked-1.2.0, xdist-1.32.0, flaky-3.6.1
collected 1 item
test_a.py::test_foo PASSED [100%]
===Flaky Test Report===
test_foo failed (2 runs remaining out of 3).
<type 'exceptions.AssertionError'>
assert 0.615803923129647 < 0.3
- where 0.615803923129647 = <built-in method random of Random object at 0x81b6f0>()
- where <built-in method random of Random object at 0x81b6f0> = random.random
[<TracebackEntry /home/sscadmin/test_a.py:8>]
test_foo passed 1 out of the required 1 times. Success!
===End Flaky Test Report===
======================================================================== 1 passed in 0.04 seconds ========================================================================
(
`
There was a problem hiding this comment.
I think you're right! Sorry about the confusion.
|
Sorry about the short delay over the long weekend. I do have one comment that needs to be addressed and then I think we're good to go with this one. |
|
Released to PyPI as version 3.7.0. |
This causes tests that fail in setup to also be considered for re-running as requested in #135