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

Refactor pytest plugin. #76

Merged
merged 3 commits into from
Dec 15, 2015
Merged

Refactor pytest plugin. #76

merged 3 commits into from
Dec 15, 2015

Conversation

Jeff-Meadows
Copy link
Contributor

This commit partially rewrites the pytest plugin so that retrying a test
includes setup and teardown of test fixtures.

This is a potentially breaking change, but it actually matches up
with how the nose plugin works and is probably what most users would want.

Fixes #53.

This commit partially rewrites the pytest plugin so that retrying a test
includes setup and teardown of test fixtures.

This is a potentially **breaking change**, but it actually matches up
with how the nose plugin works and is probably what most users would want.

Fixes #53.
@boxcla
Copy link

boxcla commented Nov 8, 2015

Verified that @Jeff-Meadows has signed the CLA. Thanks for the pull request!

@landscape-bot
Copy link

Code Health
Repository health increased by 0.08% when pulling 3dcd24b on rerun_setup into ae6c7aa on master.


[testenv:pylint]
commands =
pylint --rcfile=.pylintrc flaky
pylint --rcfile=.pylintrc test -d C0330
pylint --rcfile=.pylintrc test -d C0330,W0621
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this addition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the redefined outer name warning that has to be disabled every time you use a pytest fixture from within the same module where it's defined.

@anentropic
Copy link

is this released to pypi?

I think it may fix a problem I'm having with Flaky and Django tests... if the flaky test fails then the tearDown method gets called and Django tries to do transaction.leave_transaction_management(using=db) and this fails with TransactionManagementError: This code isn't under transaction management

I haven't got to the bottom of it yet but seems likely related to not doing the setUp/tearDown as expected

@Jeff-Meadows
Copy link
Contributor Author

Hi @anentropic I plan to release it to pypi soon!

@@ -100,6 +100,16 @@ def _log_intermediate_failure(self, err, flaky, name):
)
self._log_test_failure(name, err, message)

def _should_handle_test_error_or_failure(self, test, name, err):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring. And maybe a namedtuple return type for clarity?

Leave a note in the docstring about this function needing to be pure (not setting any state)

@jmoldow
Copy link
Contributor

jmoldow commented Dec 14, 2015

👍

@jmoldow
Copy link
Contributor

jmoldow commented Dec 14, 2015

This should be a major version bump.

Jeff-Meadows added a commit that referenced this pull request Dec 15, 2015
@Jeff-Meadows Jeff-Meadows merged commit 00dc9df into master Dec 15, 2015
def pytest_testnodedown(self, node, error):
"""
Pytest hook for responding to a test node shutting down.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a blank line after this for pep257 compliance?
(oh, already merged, sorry!)

@Jeff-Meadows Jeff-Meadows deleted the rerun_setup branch December 16, 2015 19:16
Jeff-Meadows added a commit to Jeff-Meadows/flaky that referenced this pull request Mar 15, 2016
Fixes box#96, which is a regression on box#43.
When the py.test plugin was refactored in box#76, the logic to not
retry Skipped tests was accidentally removed. This commit restores the logic
and adds a test so that we won't regress on this again.
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.

pytest: test re-run should also include resetup of all the test-scoped fixtures
6 participants