How to obtain more detailed traceback from failing testbooks

When testbooks are importing functions written in a different notebook, sometimes the traceback that you get are not very helpful.

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-9-e035eae301fc> in <module>()
----> 1 test.Angora.read_opdmr("Portal User Permissions")

C:\Users\ernesto.luzon\tronline\nboss-ci\testrunner\notebooks\Angora.ipynb in read_opdmr(self, header, target_row)

C:\Users\ernesto.luzon\tronline\nboss-ci\testrunner\notebooks\TableReaders.ipynb in get_table(self, coordinate, target_row)

IndexError: list index out of range

In order to get a more detailed traceback, you can override the imported functions by copy and pasting it to your current testbook. You will need the "register_function" to do this.

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-21-80abfe58cf7c> in <module>()
      2                    "/../../../../following-sibling::"
      3                    "div/div/table")
----> 4 browser.get_table(locator.format("Portal User Permissions"))

<ipython-input-20-145957924c5f> in get_table(self, coordinate, target_row)
     53         # This handles the rowspan
     54         for i in range(columns + index):
---> 55             dictionary[headers[i]].append(dictionary[headers[i]][-1])
     56         num += 1
     57         if target_row is not None:

IndexError: list index out of range

In [1]:
trace = 'data.pp_username = test.configparser.data("pp_username")\ndata.pp_password = test.configparser.data("pp_password")\ndata.partner = test.Angora.login_pp(data)\n\ntest.current_user = test.Angora.login_op(data)\nbrowser.press(test.current_user)\nbrowser.press("css=a[href*=\'angora-op-gui\'][href*=\'view-people\']")\ntest.Angora.search_op(" ".join(["ppu", data.partner]))\n\nbrowser.press("Edit")\ntest.Angora.select_multi_op("msl:User Permissions", "Portal Admin")\ntest.Angora.select_multi_op("msl:User Permissions", "Portal Edit")\ntest.Angora.select_multi_op("msl:User Permissions", "Portal Ticketing")\nbrowser.submit_btn("Update")', '---------------------------------------------------------------------------AttributeError                            Traceback (most recent call last)<ipython-input-15-888d32b9b72a> in <module>()\n----> 1 data.pp_username = test.configparser.data("pp_username")\n      2 data.pp_password = test.configparser.data("pp_password")\n      3 data.partner = test.Angora.login_pp(data)\n      4 \n      5 test.current_user = test.Angora.login_op(data)\nAttributeError: \'Test\' object has no attribute \'configparser\''

In [2]:
import pprint
pprint.pprint(trace)


('data.pp_username = test.configparser.data("pp_username")\n'
 'data.pp_password = test.configparser.data("pp_password")\n'
 'data.partner = test.Angora.login_pp(data)\n'
 '\n'
 'test.current_user = test.Angora.login_op(data)\n'
 'browser.press(test.current_user)\n'
 'browser.press("css=a[href*=\'angora-op-gui\'][href*=\'view-people\']")\n'
 'test.Angora.search_op(" ".join(["ppu", data.partner]))\n'
 '\n'
 'browser.press("Edit")\n'
 'test.Angora.select_multi_op("msl:User Permissions", "Portal Admin")\n'
 'test.Angora.select_multi_op("msl:User Permissions", "Portal Edit")\n'
 'test.Angora.select_multi_op("msl:User Permissions", "Portal Ticketing")\n'
 'browser.submit_btn("Update")',
 '---------------------------------------------------------------------------AttributeError                            '
 'Traceback (most recent call last)<ipython-input-15-888d32b9b72a> in '
 '<module>()\n'
 '----> 1 data.pp_username = test.configparser.data("pp_username")\n'
 '      2 data.pp_password = test.configparser.data("pp_password")\n'
 '      3 data.partner = test.Angora.login_pp(data)\n'
 '      4 \n'
 '      5 test.current_user = test.Angora.login_op(data)\n'
 "AttributeError: 'Test' object has no attribute 'configparser'")