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…]

Delayed assert / multiple failures per test

A test stops execution once it hits a failing assert statement.
That’s kinda the point of an assert statement, though, so that’s not surprising.

However, sometimes it’s useful to continue with the test even with a failing assert.

I’m going to present one method for getting around this restriction, to test multiple things, allow multiple failures per test, and continue execution after a failure.

I’m not really going to describe the code in detail, but I will give the full source so that you can take it and run with it.

[Read more…]

Book update: Python Testing with unittest, nose, pytest

This is a collection of posts that I felt would be really handy to have available all together.

Of course the introduction posts are in there too. But this is really a lot of information about quickly getting up to speed on unittest, nose, and pytest.

I’ve just updated it to fix some “glitches” in the initial eBook conversion process.

Python Testing with unittest, nose, pytest

What’s there:


[Read more…]

Best of python testing tutorials, now in epub, mobi, and pdf

I’ve put together a really good collection of posts, including tutorials for pytest, unittest, and nose, into an eBook format. Actually, three formats.

I want it!

This book is still a work in progress…
What does that mean?

I’ve updated the posts on unittest introduction and fixtures.
The nose chapters, and pytest chapters are still a little glitchy.
However, with proceeds from the book sale to help offset the cost, I’m now writing on a nice laptop that will hopefully get me writing more.

So, Updates are coming.
If you buy now at $5, you’ll get notified when things get fixed.

Python Testing with unittest, nose, pytest

Here’s what’s there:

• unittest
– unittest introduction
* Overview of unittest
* Running unittests
* Test discovery
* unittest examples
– unittest fixture syntax and flow reference
* Software Test Fixtures
* Common Case Example
* Full Test Fixture Example
* Full Test Fixture Flow
* Adding Cleanup Calls
* Skipping tests within setUp

• nose
– nose introduction
* Nose example
* Running nose
* Nose fixtures
* Nose assert_equals * Test discovery
* Running unittests from nose
* Running doctests from nose
– nose support for unittest style fixtures
– nose fixture reference
* Method, Function, Package, Module, and Class fixtures
* Full example
* Control flow
* Alternative names for fixtures

• pytest
– pytest introduction
* pytest example
* Running pytest
* pytest fixtures
* Test discovery
* Running unittests from pytest
* Running doctests from pytest
* Running nose tests from pytest
– pytest fixtures
* pytest unittest style fixtures
* pytest xUnit style fixtures
* pytest fixtures easy example
* pytest fixtures nuts and bolts
* pytest session scoped fixtures