def _CheckMatchingBrackets(self, uwlines, list_of_expected):
    """Check that the tokens have the expected matching bracket.

    Arguments:
      uwlines: list of UnwrappedLine.
      list_of_expected: list of (index, index) pairs. The matching brackets at
        the indexes need to match. Non-semantic tokens are filtered out from the
        expected values.
    """
    actual = []
    for uwl in uwlines:
      filtered_values = [(ft, ft.matching_bracket)
                         for ft in uwl.tokens
                         if ft.name not in pytree_utils.NONSEMANTIC_TOKENS]
      if filtered_values:
        actual.append(filtered_values)

    for index, bracket_list in enumerate(list_of_expected):
      uwline = actual[index]
      if not bracket_list:
        for value in uwline:
          self.assertIsNone(value[1])
      else:
        for open_bracket, close_bracket in bracket_list:
          self.assertEqual(uwline[open_bracket][0], uwline[close_bracket][1])
          self.assertEqual(uwline[close_bracket][0], uwline[open_bracket][1])
dataset/ETHPy150Open google/yapf/yapftests/pytree_unwrapper_test.py/MatchBracketsTest._CheckMatchingBrackets/original