code: def test_show_multi_test_fixture_setup_and_teardown_correctly_simple(
      pytester: Pytester,
  ) -> None:
      """Verify that when a fixture lives for longer than a single test, --setup-plan
      correctly displays the SETUP/TEARDOWN indicators the right number of times.
  
      As reported in https://github.com/pytest-dev/pytest/issues/2049
      --setup-plan was showing SETUP/TEARDOWN on every test, even when the fixture
      should persist through multiple tests.
  
      (Note that this bug never affected actual test execution, which used the
      correct fixture lifetimes. It was purely a display bug for --setup-plan, and
      did not affect the related --setup-show or --setup-only.)
      """
      pytester.makepyfile(
          """
          import pytest
          @pytest.fixture(scope = 'class')
          def fix():
              return object()
          class TestClass:
              def test_one(self, fix):
                  assert False
              def test_two(self, fix):
                  assert False
      """
      )
  
      result = pytester.runpytest("--setup-plan")
      assert result.ret == 0
  
      setup_fragment = "SETUP    C fix"
      setup_count = 0
  
      teardown_fragment = "TEARDOWN C fix"
      teardown_count = 0
  
      for line in result.stdout.lines:
          if setup_fragment in line:
              setup_count += 1
          if teardown_fragment in line:
              teardown_count += 1
  
      # before the fix this tests, there would have been a setup/teardown
      # message for each test, so the counts would each have been 2
      assert setup_count == 1
      assert teardown_count == 1
  
imports: from _pytest.pytester import Pytester
label_desc: Use image node_id 2 for calling a global function with example usage: test_show_multi_test_fixture_setup_and_teardown_correctly_simple(pytester) without return types