def test_make_xray_with_multiple_tb(self): class CustomException(Exception): def __init__(self): pass actual = bootstrap.make_xray_fault( CustomException.__name__, "test_message", "working/dir", [ ["test.py", 28, "test_method", ""], ["another_test.py", 2718, "another_test_method", ""], ], ) self.assertEqual(len(actual["exceptions"]), 1) self.assertEqual(len(actual["exceptions"][0]["stack"]), 2) self.assertEqual(actual["exceptions"][0]["stack"][0]["label"], "test_method") self.assertEqual(actual["exceptions"][0]["stack"][0]["path"], "test.py") self.assertEqual(actual["exceptions"][0]["stack"][0]["line"], 28) self.assertEqual(actual["exceptions"][0]["stack"][1]["label"], "another_test_method") self.assertEqual(actual["exceptions"][0]["stack"][1]["path"], "another_test.py") self.assertEqual(actual["exceptions"][0]["stack"][1]["line"], 2718)
def test_make_xray(self): class CustomException(Exception): def __init__(self): pass actual = bootstrap.make_xray_fault( CustomException.__name__, "test_message", "working/dir", [["test.py", 28, "test_method", "does_not_matter"]], ) self.assertEqual(actual["working_directory"], "working/dir") self.assertEqual(actual["paths"], ["test.py"]) self.assertEqual(len(actual["exceptions"]), 1) self.assertEqual(actual["exceptions"][0]["message"], "test_message") self.assertEqual(actual["exceptions"][0]["type"], "CustomException") self.assertEqual(len(actual["exceptions"][0]["stack"]), 1) self.assertEqual(actual["exceptions"][0]["stack"][0]["label"], "test_method") self.assertEqual(actual["exceptions"][0]["stack"][0]["path"], "test.py") self.assertEqual(actual["exceptions"][0]["stack"][0]["line"], 28)