[TIP] unittest.TestCase and tags

Albert-Jan Roskam fomcl at yahoo.com
Fri Apr 18 11:57:02 PDT 2014



________________________________
> From: Mateusz Łoskot <mateusz at loskot.net>
>To: testing-in-python at lists.idyll.org 
>Sent: Friday, April 18, 2014 2:31 PM
>Subject: [TIP] unittest.TestCase and tags
> 
>
>Hi,
>
>I have a collection of integration tests based on the unittest package.
>I'd like to be able to categorise tests, so I can select what kind of tests
>I want to run. For example, tests reaching local filesystem,
>tests relying on remote database servers, and so on.
>
>I found similar question has been asked in 2008 in thread
>"Tag-based execution plugin for nose?" [1] but the solution
>is based on extending unittest with metaclass [2] to enable use of nose.
>
>Is nose the only way to achieve such extensible tagging for unittest cases?
>Is the solution proposed above still recommended option or perhaps
>the unittest has got some related features in Python 3.2 or later?
>Any other mechanisms of tagging out there?
>
>[1] http://lists.idyll.org/pipermail/testing-in-python/2008-June/000731.html
>[2] http://lists.idyll.org/pipermail/testing-in-python/2008-June/000733.html


This seems nice, but it's not unittest.TestCase: http://nose.readthedocs.org/en/latest/plugins/attrib.html

$ nosetests -vv -p
...
Plugin attributeselector
  score: 100
  Selects test cases to be run based on their attributes.

  Options:
  -a, --attr
    Run only tests that have attributes specified by ATTR [NOSE_ATTR]
  -A, --eval-attr
    Run only tests for whose attributes the Python expression EXPR
    evaluates to True [NOSE_EVAL_ATTR]



More information about the testing-in-python mailing list