Fix test_dispatch.py when running with TORCH_SHOW_CPP_STACKTRACES=1 (#50509)

Summary:
`test_dispatch.py` has many asserts about the error message. When running with `TORCH_SHOW_CPP_STACKTRACES=1`, the error message is different from when `TORCH_SHOW_CPP_STACKTRACES=0`, which makes many tests in `test_dispatch.py` fail. This PR fixes these failures when running with `TORCH_SHOW_CPP_STACKTRACES=1`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/50509

Reviewed By: ngimel

Differential Revision: D25956853

Pulled By: ezyang

fbshipit-source-id: 3b3696742a7dfb8f52f23a364838ec96945c5662
This commit is contained in:
Xiang Gao
2021-01-20 10:10:25 -08:00
committed by Facebook GitHub Bot
parent f1c578594b
commit 4f3cdd971c
2 changed files with 13 additions and 4 deletions

View File

@ -138,6 +138,7 @@ class TestDispatch(TestCase):
if not expect_raises:
raise
actual = str(e).replace(test_namespace, "test")
actual = actual.split("\nException raised from ")[0]
expected, _, expected_provenance = results.setdefault(
frozenset(active_ops),
Result(actual, "", "error after running ctors {}".format(ctor_order[:i + 1]))