Skip to content

Latest commit

 

History

History

ch_5_parametrization

Chapter 5. Parametrization


AUT: Cards (To-Do List)

  1. Function parametrization
  2. Fixture parametrization
  3. Hooks (pytest_generate_tests)

1.1 pytest_generate_tests & Metafunc

  • We could base parametrization list on a command-line flag:

metafunc.config.getoption("--someflag")

  • We could parametrize multiple parameters:

metafunc.paramterize("planet, moon", [ ('Earth', 'Moon'), ('Mars', 'Deimos'), ('Mars', 'Phobos), ])

1.2 Running subset of tests

  1. Parameteres can be used to gather a smaller subset of tests:

pytest -v -k todo

pytest -v -k "todo and not (done or play)"