pytest delayed assert / multiple failure plugin, iteration 1

In Delayed assert / multiple failures per test, I presented a first attempt at writing an ‘expect()’ function that will allow
a test function to collect multiple failures and not stop execution until the end of the test.

There’s one big thing about that method that I don’t like.
I don’t like having to call ‘assert_expectations()’ within the test.
It would be cool to push that part into a plugin.

So, even though this isn’t the prettiest code, here’s a first attempt at making this a plugin.

[Read more…]

pytest fixtures nuts and bolts

I’d like to wrap up this recent series of pytest fixture posts by presenting my version of some sort of reference.
Since this post is running a bit long, here are some links to the content buried in here.

[Read more…]

pytest fixtures easy example

In pytest xUnit style fixtures, I presented a problem where:

  • Two tests exist in a test file.
  • One uses a resource.
  • The other doesn’t.
  • Module level fixtures don’t work if you just want to run the one function that doesn’t use the resource.

I then presented class level fixtures as a way to solve the separation problem.

In this post, I’ll use pytest fixtures to solve the same problem.
I’m not going into details of all the goodies you get with pytest fixtures.
I’ll just stick to solving this problem.
[Read more…]