abseil/abseil-py

AbslTest.assertSameStructure() doesn't work with TestCase.addTypeEqualityFunc()

georgevdd opened this issue · 0 comments

assertSameStructure() uses plain == to compare leaf nodes (here). It would be useful if it instead used functions registered with addTypeEqualityFunc() in the same way that TestCase.assertEqual() does.

In particular, this would make it easy to compare trees of NumPy arrays. As things stand, self.assertSameStructure(numpy_tree_1, numpy_tree_2) fails like:

  File "[...]/absl/testing/absltest.py", line 1988, in _walk_structure_for_problems
    _walk_structure_for_problems(
  File "[...]/absl/testing/absltest.py", line 2017, in _walk_structure_for_problems
    if a != b:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()