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

Add a pytest plugin to fix fixture handling #152

Merged
merged 1 commit into from
Jun 16, 2016
Merged

Conversation

cdent
Copy link
Owner

@cdent cdent commented Jun 10, 2016

This is a backwards compatible improvement to the way gabbi works
with pytest. Tests are loaded (and yielded in the same way) but
they are filtered more correctly, and fixture start and stops are
done more correctly.

This allows the test count to be accurate and test selection (using
-k) to work properly.

Fixes #128
Fixes #123

The details of this change are more clear with an understanding of
how pytest plugins and hooks work, but the gist is that a plugin has
been created and then forcibly installed. The plugin traverse the
collected tests to find and filter out the two tests associated with
each suite that start and stop fixtures. These are attached as
attributes to the first and last selected (if any) tests in the
relevant suite. When a test is asked to run:

  • if it has a 'starter', the start will run
  • then the test will run itself
  • it has a prior that has not run, that will be run
  • as the tests run if a test with a 'stopper' is found, the stopper
    will be run

This is a backwards compatible improvement to the way gabbi works
with pytest. Tests are loaded (and yielded in the same way) but
they are filtered more correctly, and fixture start and stops are
done more correctly.

This allows the test count to be accurate and test selection (using
-k) to work properly.

Fixes #128
Fixes #123

The details of this change are more clear with an understanding of
how pytest plugins and hooks work, but the gist is that a plugin has
been created and then forcibly installed. The plugin traverse the
collected tests to find and filter out the two tests associated with
each suite that start and stop fixtures. These are attached as
attributes to the first and last selected (if any) tests in the
relevant suite. When a test is asked to run:

* if it has a 'starter', the start will run
* then the test will run itself
* it has a prior that has not run, that will be run
* as the tests run if a test with a 'stopper' is found, the stopper
  will be run
@cdent
Copy link
Owner Author

cdent commented Jun 10, 2016

@jasonamyers and @josdotso this is probably relevant for the stuff you are working on, if you could take a look that would be great

@ghost
Copy link

ghost commented Jun 17, 2016

@cdent Sorry I didn't get a chance to look at this during this week. I've been traveling for training. I'm going to keep this in my inbox to eventually take a look though. Thanks!

@cdent
Copy link
Owner Author

cdent commented Jun 17, 2016

No worries @josdotso. I've gone ahead and merged it and it is 1.23.0. My testing seemed to indicate that it is working correctly. If you do get a chance to check it out and it is busted please let me know asap.

I'll be travelling too, early next week, but mostly around otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant