mdmintz / pdbp

pdbp (Pdb+): A drop-in replacement for pdb and pdbpp. To replace "pdb", add "import pdbp" to an "__init__.py" file.
Other
69 stars 2 forks source link

Include the module name in the exception, except with "builtins" #44

Closed mdmintz closed 1 year ago

mdmintz commented 1 year ago

Include the module name in the exception, except with builtins

Eg. KeyError is really builtins.KeyError, but since it is part of builtins, the builtins part isn't necessary.

But in the case of NoSuchElementException, show the full selenium.common.exceptions.NoSuchElementException.

This can help reduce confusion, especially when different libraries have the same exception name:

Eg.

selenium.common.exceptions.NoSuchElementException
seleniumbase.common.exceptions.NoSuchElementException

An example of expected output in a full exception message:

seleniumbase.common.exceptions.NoSuchElementException:
 Element {div#ARMY_OF_ROBOTS} was not present after 1 second!

Expected output from pdbp Debug Mode:

[1] > /Users/michael/github/SeleniumBase/examples/test_fail.py(16)
  ..
  12         @pytest.mark.expected_failure
  13         def test_find_army_of_robots_on_xkcd_desert_island(self):
  14             self.open("https://xkcd.com/731/")
  15             print("\n(This test should fail)")
  16  ->         self.assert_element("div#ARMY_OF_ROBOTS", timeout=1)
seleniumbase.common.exceptions.NoSuchElementException: 
 Element {div#ARMY_OF_ROBOTS} was not present after 1 second!
(Pdb+)