code: def test_fields(self, periodindex, field):
      periods = list(periodindex)
      ser = Series(periodindex)
  
      field_idx = getattr(periodindex, field)
      assert len(periodindex) == len(field_idx)
      for x, val in zip(periods, field_idx):
          assert getattr(x, field) == val
  
      if len(ser) == 0:
          return
  
      field_s = getattr(ser.dt, field)
      assert len(periodindex) == len(field_s)
      for x, val in zip(periods, field_s):
          assert getattr(x, field) == val
  
file_path: pandas/pandas/tests/indexes/period/test_period.py
imports: import numpy
  import pytest
  from pandas import Index, NaT, Period, PeriodIndex, Series, date_range, offsets, period_range
  import pandas._testing
label_desc: Use image node_id 3 for calling the TestPeriodIndex obj's underlying member method code with example usage: obj.test_fields(periodindex, field) without return types