143: pytest markers - Anthony Sottile
Completely nerding out about pytest markers with Anthony Sottile.
Some of what we talk about:
- Running a subset of tests with markers.
- Using marker expressions with and, or, not, and parentheses.
- Keyword expressions also can use and, or, not, and parentheses.
- Markers and pytest functionality that use mark, such as parametrize, skipif, etc.
- Accessing markers with itermarkers and get_closest_marker through item.
- Passing values, metadata through markers to fixtures or hook functions.
Links:
- Registering markers
- slow marker example in pytest documentation — Control skipping of tests according to command line option
- pytest-repeat · PyPI
- source code for pytest-repeat
- Working with custom markers — pytest documentation
- Using -k expr to select tests based on their name
- Marker revamp and iteration, Historical Notes — pytest documentation
Help support the show AND learn pytest:
- The Complete pytest course is now a bundle, with each part available separately.
- pytest Primary Power teaches the super powers of pytest that you need to learn to use pytest effectively.
- Using pytest with Projects has lots of "when you need it" sections like debugging failed tests, mocking, testing strategy, and CI
- Then pytest Booster Rockets can help with advanced parametrization and building plugins.
- Whether you need to get started with pytest today, or want to power up your pytest skills, PythonTest has a course for you.
Creators and Guests
