Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Python Testing with pytest
About the Pragmatic Bookshelf
Table of Contents
Early praise for Python Testing with pytest
Acknowledgments
Preface
What Is pytest?
Learn pytest While Testing an Example Applicati on
How This Book Is Organized
What You Need to Know
Example Code and Online Resources
Chapter 1: Getting Started with pytest
Getting pytest
Running pytest
Running Only One Test
Using Options
Exercises
What’s Next
Chapter 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
Chapter 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
Chapter 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
Chapter 5: Plugins
Finding Plugins
Installing Plugins
Writing Your Own Plugins
Creating an Installable Plugin
Testing Plugins
Creating a Distribution
Exercises
What’s Next
Chapter 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 Pla ces
Specifying Test Directory Locations
Changing Test Discovery Rules
Disallowing XPASS
Avoiding Filename Collisions
Exercises
What’s Next
Chapter 7: Using pytest with Other Tools
pdb: Debugging Test Failures
Coverage.py: Determining How Much Code Is Test ed
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
Appendix 1: Virtual Environments
Appendix 2: pip
Appendix 3: 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
Appendix 4: Packaging and Distributing Python Projects
Creating an Installable Module
Creating an Installable Package
Creating a Source Distribution and Wheel
Creating a PyPI-Installable Package
Appendix 5: xUnit Fixtures
Syntax of xUnit Fixtures
Mixing pytest Fixtures and xUnit Fixtures
Limitations of xUnit Fixtures
You May Be Interested In…
← Prev
Back
Next →
← Prev
Back
Next →