I’ve got the test code from my unittest fixture syntax and flow reference, and I want to try to run one class, say TestSkip from unittest, nosetests, and pytest, to compare the the control flow.

Therefore, I need for each framework:

  • The option to make it as quiet as possible (-q for all of them)
  • The option to turn off output capture (-s works for both pytest and nose, not needed for unittest)
  • The way to call an individual class (this is where they all differ.

unittest

Specify moduleName.className, like so:

python -m unittest -q test_fixtures.TestSkip

nosetests

Specify moduleName:className, like so:

nosetests -q -s test_fixtures:TestSkip

pytest

Specify fileName.py::className, like so:

py.test -q -s test_fixtures.py::TestSkip

I originally described using -k expression to pick the test — Thanks Holger, for the correction and info!!

Preliminary results

I’m still working on a comparison of the unittest fixture compliance with nose and py.test.
However, so far, they both look pretty good, with one exception.
It doesn’t look like the version of pytest I’m running (2.3.5) supports unittest setUpModule() and tearDownModule().
I know it supports the nose-like setup_module() and teardown_module(), but apparently not the unittest spelling of these functions.

I’ll go through a more thorough comparison in a future post.