GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — flake8-pytest-style/docs/rules/PT022.md at master · m-burst/flake8-pytest-style

Expand file tree

/

PT022.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
39 lines (28 loc) · 673 Bytes
/

PT022.md

Copy path

File metadata and controls

39 lines (28 loc) · 673 Bytes
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

PT022

no teardown in fixture {name}, use return instead of yield

yield in fixtures is only useful and semantically correct when the fixture contains some teardown code.

Examples

Bad code:

import pytest

@pytest.fixture()
def my_fixture():
    resource = acquire_resource()
    yield resource

Good code:

import pytest

@pytest.fixture()
def my_fixture_with_teardown():
    resource = acquire_resource()
    yield resource
    resource.release()

@pytest.fixture()
def my_fixture_without_teardown():
    resource = acquire_resource()
    return resource

Rationale

  • to make sure that all yield usages are semanticaly correct
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.