[pytest-dev] request for feedback, pytest-suites - a plugin to execute a subset of tests

Bryan Berry bryan.berry at gmail.com
Mon Feb 6 23:16:06 EST 2017

Hey folks!

I have made a little plugin that makes it easier to executes subsets of
your tests. I would very much appreciate your feedback on it.


This plugin determines which tests belong in a suite by applying UNIX-style
to the test function name. A suite consists of a name, pattern (glob) or
patterns, and
additional metadata.

First, add pytest-suites to your conftest.py

   # conftest.py

   pytest_plugins = ['suites']

Next you will likely want to define a suite or two. Also do this in

   # conftest.py

   from pytest_suites import add_suite

   add_suite(name="smoke", pattern="*basic*")
   add_suite(name="advanced", pattern="*")
   add_suite(name="extended", pattern="*", tags={'mode': 'extended'})

Meanwhile, add some tests:

  # my_test.py

  def test_basic_feature1():
      assert True

  def test_basic_feature2():
      assert True

  def test_advanced_feature1():
      assert True

  def test_advanced_feature1():
      assert True

Use the command-line option ``--suite SUITE`` to specify the suite

Executing ``pytest my_test.py --suite smoke`` will only execute the tests
`test_basic_feature1` and `test_basic_feature2`.

pytest-suites provides a mechanism for running tests to learn what suite is
currently being executed and access the suite's tags dictionary. This can be
useful when you want to occasionally test less or greater functionality
within a
given test. For example, you may frequently want `test_my_feature` to check
common case but right before a release you may the same test to be more

  def test_advanced_feature1(suite):
      mode = suite.tags.get('mode', 'basic')
      if mode == 'extended':
          # test exhaustively
          assert do_expensive_operation()
          # test the common case
          assert True

That's pretty much it! there is a little more info on the github page. I
plan to publish this to pypi shortly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20170207/17bb9664/attachment.html>

More information about the pytest-dev mailing list