Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
pytest Quick Start Guide

You're reading from   pytest Quick Start Guide Write better Python code with simple and maintainable tests

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789347562
Length 160 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Oliveira Oliveira
Author Profile Icon Oliveira
Oliveira
Arrow right icon
View More author details
Toc

Index

A

  • abstract syntax tree (AST) / How does pytest do it?
  • Adopt pytest month / Next steps
  • asserts
    • converting, with unitest2pytest / Converting asserts with unitest2pytest
  • assorted plugins
    • overview / An overview of assorted plugins
    • pytest-xdist / pytest-xdist
    • pytest-cov / pytest-cov
    • pytest-faulthandler / pytest-faulthandler
    • pytest-mock / pytest-mock
    • pytest-django / pytest-django
    • pytest-flakes / pytest-flakes
    • pytest-asyncio / pytest-asyncio
    • pytest-trio / pytest-trio
    • pytest-tornado / pytest-tornado
    • pytest-postgresql / pytest-postgresql
    • docker-services / docker-services
    • pytest-selenium / pytest-selenium
    • pytest-html / pytest-html
    • pytest-cpp / pytest-cpp
    • pytest-timeout / pytest-timeout
    • pytest-annotate / pytest-annotate
    • pytest-qt / pytest-qt
    • pytest-randomly / pytest-randomly
    • pytest-datadir / pytest-datadir
    • pytest-regressions / pytest-regressions
  • asyncio
    • reference link / pytest-asyncio
  • automated tests / Why spend time writing tests? 
  • autouse
    • about / Autouse
    • @pytest.mark.usefixtures, using / @pytest.mark.usefixtures

B

  • boost.org
    • reference link / pytest-cpp
  • built-in fixtures
    • overview / An overview of built-in fixtures
    • tmpdir / tmpdir
    • tmpdir_factory / tmpdir_factory
    • monkeypatch / monkeypatch
    • capsys / capsys/capfd
    • capfd / capsys/capfd
    • request / request

C

  • capfd
    • about / capsys/capfd
    • binary mode / Binary mode
  • capsys
    • about / capsys/capfd
    • binary mode / Binary mode
  • command-line options
    • about / Useful command-line options
    • keyword expressions / Keyword expressions: -k
    • stop soon / Stop soon: -x, --maxfail
    • failed tests / Last failed, failed first: --lf, --ff
    • output capturing / Output capturing: -s and --capture
    • traceback modes and locals / Traceback modes and locals: --tb, --showlocals
    • slow tests, with --durations / Slow tests with --durations
    • test summary / Extra test summary: -ra
  • conftest.py files
    • fixtures, sharing with / Sharing fixtures with conftest.py files
    • local imports, preferring / Prefer local imports in conftest files
  • context manager
    • reference link / Setup/teardown

D

  • Django
    • reference link / pytest-django
  • docker-services / docker-services

F

  • faulthandler
    • reference link / pytest-faulthandler
  • file-descriptor level / Capture methods with --capture
  • files
    • organizing / Organizing files and packages
  • fixtures
    • about / Introducing fixtures, Tips/discussion, Fixtures, Why pytest?
    • using / Enter fixtures
    • setup / Setup/teardown
    • teardown / Setup/teardown
    • composability / Composability
    • sharing, with conftest.py files / Sharing fixtures with conftest.py files
    • parametrizing / Parametrizing fixtures
    • marks, using from / Using marks from fixtures
    • using, to avoid simple functions / When to use fixtures, as opposed to simple functions
    • renaming / Renaming fixtures
    • using, as test-supporting code / Fixtures as test-supporting code
    • used, for reusing test code / Reusing test code with fixtures

G

  • global variable / Applying marks to modules

L

  • local imports / Prefer local imports in conftest files

M

  • marks
    • basics / Mark basics
    • creating / Creating marks, Marks and parametrization
    • tests, executing / Running tests based on marks
    • applying, to classes / Applying marks to classes
    • applying, to modules / Applying marks to modules
    • about / Custom marks and pytest.ini
    • pytest.ini / Custom marks and pytest.ini
    • built-in / Built-in marks
    • @pytest.mark.skipif / @pytest.mark.skipif
    • @pytest.mark.xfail / @pytest.mark.xfail
    • using, from fixtures / Using marks from fixtures
  • migration strategy / Migration strategy
  • monkeypatch
    • about / monkeypatch
    • using / How and where to patch
    • working / How and where to patch

O

  • output capturing, command line options
    • disabling, with -s / Disabling capturing with -s
    • capture methods, with --capture / Capture methods with --capture

P

  • @pytest.mark.skipif, marks
    • pytest.skip / pytest.skip
    • pytest.importorskip / pytest.importorskip
  • @pytest.mark.usefixtures
    • using / @pytest.mark.usefixtures
  • @pytest.mark.xfail, marks
    • pytest.xfail / pytest.xfail
  • packages
    • organizing / Organizing files and packages
  • parametrization
    • about / Parametrization, Marks and parametrization
    • @pytest.mark.parametrize / Enter @pytest.mark.parametrize
    • marks, applying to value sets / Applying marks to value sets
    • test IDs, customizing / Customizing test IDs
    • multiple implementations, testing / Testing multiple implementations
  • pathlib
    • reference link / pytest-datadir
  • plugins / Plugins
    • searching / Finding and installing plugins, Finding plugins
    • installing / Finding and installing plugins, Installing plugins
    • improving / Getting involved
  • PyAnnotate
    • reference link / pytest-annotate
  • pytest
    • installing / Installing pytest
    • installing, using pip / pip and virtualenv
    • installing, using virtualenv / pip and virtualenv
    • used, for writing tests / Writing and running tests
    • used, for executing tests / Writing and running tests, Running tests
    • used, for powerful asserts / Powerful asserts
    • test modules, with code / Tests that accompany your code
    • tests, separating from code / Tests separate from your code
    • using, as test runner / Using pytest as a test runner
    • features, in unittest subclasses / Pytest features in unittest subclasses
    • writing / Writing and running tests
    • executing / Writing and running tests
    • converting, to unittest suites / Converting unittest suites to pytest
    • improving / Getting involved
    • need for / Why pytest?
  • pytest, power asserts
    • text differences / Text differences
    • lists /
    • dictionaries and sets / Dictionaries and sets
    • implementing / How does pytest do it?
    • exception messages, checking / Checking exceptions: pytest.raises, Checking exception messages
    • warnings, checking / Checking warnings: pytest.warns
    • floating point numbers, comparing / Comparing floating point numbers: pytest.approx
  • pytest-annotate / pytest-annotate
  • pytest-asyncio / pytest-asyncio
  • pytest-cov / pytest-cov
  • pytest-cpp / pytest-cpp
  • pytest-datadir / pytest-datadir
  • pytest-django / pytest-django
  • pytest-flakes / pytest-flakes
  • pytest-html / pytest-html
  • pytest-mock / pytest-mock
  • pytest-postgresql / pytest-postgresql
  • pytest-qt / pytest-qt
  • pytest-randomly / pytest-randomly
  • pytest-regressions / pytest-regressions
  • pytest-selenium / pytest-selenium
  • pytest-timeout / pytest-timeout
  • pytest-tornado / pytest-tornado
  • pytest-trio / pytest-trio
  • pytest-xdist / pytest-xdist
  • pytest.ini
    • configuring / Configuration: pytest.ini
    • command-line options / Additional command-line: addopts
    • collection, customizing / Customizing a collection
    • cache directory / Cache directory: cache_dir
    • recurse, avoiding into directories / Avoid recursing into directories: norecursedirs
    • testpaths / Pick the right place by default: testpaths
    • options, overriding with -o/--override / Override options with -o/--override
  • pytest community / The pytest community

R

  • refactoring-heaven mode / --tb=line

S

  • 2016 Sprint / 2016 Sprint
  • scopes
    • about / Scopes
    • working with / Scopes in action
  • selenium
    • reference link / pytest-selenium
  • setup
    • handling / Handling setup/teardown

T

  • teardown
    • handling / Handling setup/teardown
  • test hierarchies
    • managing / Managing test hierarchies
    • test code, reusing with fixtures / Reusing test code with fixtures
  • test suite / Why spend time writing tests? 
  • test utilities
    • refactoring / Refactoring test utilities
  • tmpdir / tmpdir
  • tmpdir_factory / tmpdir_factory
  • Tornado
    • reference link / pytest-tornado
  • tox / Next steps
  • traceback modes and locals, command-line options
    • --tb=long / --tb=long
    • --tb=short / --tb=short
    • --tb=native / --tb=native
    • --tb=line / --tb=line
    • --tb=no / --tb=no
    • --showlocals (-l) / --showlocals (-l)

U

  • unitest2pytest
    • used, for converting asserts / Converting asserts with unitest2pytest
  • unittest.mock
    • reference link / pytest-mock
  • unittest module / A quick look at the unittest module
  • unittest suites
    • converting, to pytest / Converting unittest suites to pytest

V

  • VCR.py
    • reference link / Honorable mentions
  • virtualenv
    • reference link / pip and virtualenv

W

  • whenever
    • request / request
lock icon The rest of the chapter is locked
arrow left Previous Section
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images