Home Page Icon
Home Page
Table of Contents for
Title Page
Close
Title Page
by Brian Okken
Python Testing with pytest
 Acknowledgments
 Preface
What Is pytest?
Learn pytest While Testing an Example Application
How This Book Is Organized
What You Need to Know
Example Code and Online Resources
1. Getting Started with pytest
Getting pytest
Running pytest
Running Only One Test
Using Options
Exercises
What’s Next
2. Writing Test Functions
Testing a Package
Using assert Statements
Expecting Exceptions
Marking Test Functions
Skipping Tests
Marking Tests as Expecting to Fail
Running a Subset of Tests
Parametrized Testing
Exercises
What’s Next
3. pytest Fixtures
Sharing Fixtures Through conftest.py
Using Fixtures for Setup and Teardown
Tracing Fixture Execution with –setup-show
Using Fixtures for Test Data
Using Multiple Fixtures
Specifying Fixture Scope
Specifying Fixtures with usefixtures
Using autouse for Fixtures That Always Get Used
Renaming Fixtures
Parametrizing Fixtures
Exercises
What’s Next
4. Builtin Fixtures
Using tmpdir and tmpdir_factory
Using pytestconfig
Using cache
Using capsys
Using monkeypatch
Using doctest_namespace
Using recwarn
Exercises
What’s Next
5. Plugins
Finding Plugins
Installing Plugins
Writing Your Own Plugins
Creating an Installable Plugin
Testing Plugins
Creating a Distribution
Exercises
What’s Next
6. Configuration
Understanding pytest Configuration Files
Changing the Default Command-Line Options
Registering Markers to Avoid Marker Typos
Requiring a Minimum pytest Version
Stopping pytest from Looking in the Wrong Places
Specifying Test Directory Locations
Changing Test Discovery Rules
Disallowing XPASS
Avoiding Filename Collisions
Exercises
What’s Next
7. Using pytest with Other Tools
pdb: Debugging Test Failures
Coverage.py: Determining How Much Code Is Tested
mock: Swapping Out Part of the System
tox: Testing Multiple Configurations
Jenkins CI: Automating Your Automated Tests
unittest: Running Legacy Tests with pytest
Exercises
What’s Next
A1. Virtual Environments
A2. pip
A3. Plugin Sampler Pack
Plugins That Change the Normal Test Run Flow
Plugins That Alter or Enhance Output
Plugins for Static Analysis
Plugins for Web Development
A4. Packaging and Distributing Python Projects
Creating an Installable Module
Creating an Installable Package
Creating a Source Distribution and Wheel
Creating a PyPI-Installable Package
A5. xUnit Fixtures
Syntax of xUnit Fixtures
Mixing pytest Fixtures and xUnit Fixtures
Limitations of xUnit Fixtures
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
Python Testing with pytest
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset