diff --git a/README.md b/README.md index 13ac2b9d..465ae4ff 100755 --- a/README.md +++ b/README.md @@ -451,7 +451,7 @@ pytest my_first_test.py --demo ```python import time; time.sleep(5) # Makes the test wait and do nothing for 5 seconds. -import ipdb; ipdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step. +import pdb; pdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step. import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continue, s = step. ``` @@ -461,7 +461,7 @@ import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continu pytest my_first_test.py --pdb ``` -(**``ipdb``** console commands: ``n``, ``c``, ``s`` => ``next``, ``continue``, ``step``). +(**``pdb``** console commands: ``n``, ``c``, ``s`` => ``next``, ``continue``, ``step``). 🔵 Here are some useful command-line options that come with pytest: diff --git a/examples/master_qa/pytest.ini b/examples/master_qa/pytest.ini index ac4f1c71..b3d1df11 100644 --- a/examples/master_qa/pytest.ini +++ b/examples/master_qa/pytest.ini @@ -1,7 +1,7 @@ [pytest] -# Display console output, disable cacheprovider, and have the ipdb debugger replace pdb: -addopts = --capture=no -p no:cacheprovider --pdbcls=IPython.terminal.debugger:TerminalPdb +# Display console output, disable cacheprovider: +addopts = --capture=no -p no:cacheprovider # Ignore warnings such as DeprecationWarning and PytestUnknownMarkWarning filterwarnings = diff --git a/examples/migration/raw_selenium/pytest.ini b/examples/migration/raw_selenium/pytest.ini index 2829a8c2..abc3afd9 100644 --- a/examples/migration/raw_selenium/pytest.ini +++ b/examples/migration/raw_selenium/pytest.ini @@ -1,7 +1,7 @@ [pytest] -# Display console output, disable cacheprovider, and have the ipdb debugger replace pdb: -addopts = --capture=no -p no:cacheprovider --pdbcls=IPython.terminal.debugger:TerminalPdb +# Display console output, disable cacheprovider: +addopts = --capture=no -p no:cacheprovider # Ignore warnings such as DeprecationWarning and PytestUnknownMarkWarning filterwarnings = diff --git a/examples/translations/pytest.ini b/examples/translations/pytest.ini index 502b0f8b..6ae9dfc3 100644 --- a/examples/translations/pytest.ini +++ b/examples/translations/pytest.ini @@ -1,7 +1,7 @@ [pytest] -# Display console output, disable cacheprovider, and have the ipdb debugger replace pdb: -addopts = --capture=no -p no:cacheprovider --pdbcls=IPython.terminal.debugger:TerminalPdb +# Display console output, disable cacheprovider: +addopts = --capture=no -p no:cacheprovider # Ignore warnings such as DeprecationWarning and PytestUnknownMarkWarning filterwarnings = diff --git a/help_docs/chinese.md b/help_docs/chinese.md index 2a111d78..b8de4925 100644 --- a/help_docs/chinese.md +++ b/help_docs/chinese.md @@ -325,11 +325,11 @@ pytest --collect-only -q ``` 您可以在脚本中使用以下内容来帮助您调试问题: -(如果使用ipdb,请确保将“-s”添加到命令行选项中,除非已经在pytest.ini中) +(如果使用pdb,请确保将“-s”添加到命令行选项中,除非已经在pytest.ini中) ```python import time; time.sleep(5) # Makes the test wait and do nothing for 5 seconds. -import ipdb; ipdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step. +import pdb; pdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step. import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continue, s = step. ``` @@ -339,7 +339,7 @@ import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continu pytest my_first_test.py --pdb -s ``` -上面的代码将在出现故障时打开浏览器窗口。(ipdb命令:'n', 'c', 's' => next, continue, step)。 +上面的代码将在出现故障时打开浏览器窗口。(pdb命令:'n', 'c', 's' => next, continue, step)。 下面是Pytest附带的一些有用的命令行选项: diff --git a/help_docs/customizing_test_runs.md b/help_docs/customizing_test_runs.md index e7a4b274..db1d660f 100755 --- a/help_docs/customizing_test_runs.md +++ b/help_docs/customizing_test_runs.md @@ -250,7 +250,7 @@ You can use the following calls in your scripts to help you debug issues: ```python import time; time.sleep(5) # Makes the test wait and do nothing for 5 seconds. -import ipdb; ipdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step. +import pdb; pdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step. import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continue, s = step. ``` @@ -260,7 +260,7 @@ To pause an active test that throws an exception or error, add ``--pdb -s``: pytest my_first_test.py --pdb -s ``` -The code above will leave your browser window open in case there's a failure. (ipdb commands: 'c', 's', 'n' => continue, step, next). +The code above will leave your browser window open in case there's a failure. (pdb commands: 'c', 's', 'n' => continue, step, next).

Combinations of options:

diff --git a/help_docs/recorder_mode.md b/help_docs/recorder_mode.md index 739e393c..9edd4fc7 100755 --- a/help_docs/recorder_mode.md +++ b/help_docs/recorder_mode.md @@ -26,12 +26,20 @@ sbase mkrec new_test.py --url=wikipedia.org pytest new_test.py --rec -q -s --url=wikipedia.org -> .../SeleniumBase/examples/new_test.py(7)test_recording() - 5 def test_recording(self): - 6 if self.recorder_ext and not self.xvfb: -----> 7 import ipdb; ipdb.set_trace() +>>>>>>>>>>>>>>>>>> PDB set_trace >>>>>>>>>>>>>>>>> -ipdb> c +-> import pdb; pdb.set_trace() +> .../YOUR_CURRENT_DIRECTORY/new_test.py(9) + + 5 def test_recording(self): + 6 if self.recorder_ext and not self.xvfb: + 7 # When you are done recording actions, + 8 # type "c" and press [ENTER] to continue + 9 -> import pdb; pdb.set_trace() + return None +(Pdb++) c + +>>>>>>>>>>>>>>>>>> PDB continue >>>>>>>>>>>>>>>>>> >>> RECORDING SAVED as: recordings/new_test_rec.py ************************************************** @@ -71,7 +79,7 @@ The first command creates a boilerplate test with a breakpoint; the second comma ⏺️ You can also use the Recorder to add code to an existing test. To do that, you'll first need to create a breakpoint in your code to insert manual browser actions: ```python -import ipdb; ipdb.set_trace() +import pdb; pdb.set_trace() ``` Now you'll be able to run your test with ``pytest``, and it will stop at the breakpoint for you to add in actions: (Press ``c`` and ``ENTER`` on the command-line to continue from the breakpoint.) @@ -80,7 +88,7 @@ Now you'll be able to run your test with ``pytest``, and it will stop at the bre pytest TEST_NAME.py --rec -s ``` -⏺️ You can also set a breakpoint at the start of your test by adding ``--trace`` as a ``pytest`` command-line option: (This is useful when running Recorder Mode without any ``ipdb`` breakpoints.) +⏺️ You can also set a breakpoint at the start of your test by adding ``--trace`` as a ``pytest`` command-line option: (This is useful when running Recorder Mode without any ``pdb`` breakpoints.) ```bash pytest TEST_NAME.py --trace --rec -s diff --git a/pytest.ini b/pytest.ini index 1b641e0e..69d3cc3f 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,7 +1,7 @@ [pytest] -# Display console output, disable cacheprovider, and have the ipdb debugger replace pdb: -addopts = --capture=no -p no:cacheprovider --pdbcls=IPython.terminal.debugger:TerminalPdb +# Display console output, disable cacheprovider: +addopts = --capture=no -p no:cacheprovider # Ignore warnings such as DeprecationWarning and PytestUnknownMarkWarning filterwarnings = diff --git a/seleniumbase/__init__.py b/seleniumbase/__init__.py index f0143f2a..7f5adca6 100755 --- a/seleniumbase/__init__.py +++ b/seleniumbase/__init__.py @@ -1,4 +1,5 @@ import collections +import pdb import sys from selenium import webdriver from seleniumbase.__version__ import __version__ @@ -14,6 +15,15 @@ from seleniumbase.plugins.sb_manager import SB # noqa from seleniumbase.plugins.driver_manager import Driver # noqa from seleniumbase.plugins.driver_manager import DriverContext # noqa +if hasattr(pdb, "DefaultConfig"): + # Only load pdbpp configuration if pdbpp is installed + pdb.DefaultConfig.filename_color = pdb.Color.blue + pdb.DefaultConfig.line_number_color = pdb.Color.turquoise + pdb.DefaultConfig.show_hidden_frames_count = False + pdb.DefaultConfig.disable_pytest_capturing = True + pdb.DefaultConfig.enable_hidden_frames = False + pdb.DefaultConfig.truncate_long_lines = True + pdb.DefaultConfig.sticky_by_default = True if sys.version_info[0] >= 3: from seleniumbase import translate # noqa if sys.version_info >= (3, 7): diff --git a/seleniumbase/console_scripts/run.py b/seleniumbase/console_scripts/run.py index 4ca22ffc..ffb9f824 100644 --- a/seleniumbase/console_scripts/run.py +++ b/seleniumbase/console_scripts/run.py @@ -259,7 +259,7 @@ def show_mkfile_usage(): print(" sbase mkfile new_test.py") print(" Options:") print(" -b / --basic (Basic boilerplate / single-line test)") - print(" -r / --rec (adds ipdb breakpoint for Recorder Mode)") + print(" -r / --rec (add pdb++ breakpoint for Recorder Mode)") print(" Language Options:") print(" --en / --English | --zh / --Chinese") print(" --nl / --Dutch | --fr / --French") diff --git a/seleniumbase/console_scripts/sb_mkdir.py b/seleniumbase/console_scripts/sb_mkdir.py index 24544c7f..bde64602 100755 --- a/seleniumbase/console_scripts/sb_mkdir.py +++ b/seleniumbase/console_scripts/sb_mkdir.py @@ -123,10 +123,7 @@ def main(): data = [] data.append("[pytest]") - data.append( - "addopts = --capture=no -p no:cacheprovider " - "--pdbcls=IPython.terminal.debugger:TerminalPdb" - ) + data.append("addopts = --capture=no -p no:cacheprovider") data.append("filterwarnings =") data.append(" ignore::pytest.PytestWarning") data.append(" ignore:.*U.*mode is deprecated:DeprecationWarning") @@ -165,9 +162,6 @@ def main(): data.append("[flake8]") data.append("exclude=recordings,temp") data.append("") - data.append("[ipdb]") - data.append("context=5") - data.append("") data.append("[nosetests]") data.append("nocapture=1") data.append("logging-level=INFO") diff --git a/seleniumbase/console_scripts/sb_mkfile.py b/seleniumbase/console_scripts/sb_mkfile.py index 2970ae14..6b289498 100755 --- a/seleniumbase/console_scripts/sb_mkfile.py +++ b/seleniumbase/console_scripts/sb_mkfile.py @@ -11,7 +11,7 @@ Example: Options: -b / --basic (Basic boilerplate / single-line test) - -r / --rec (adds ipdb breakpoint for Recorder Mode) + -r / --rec (add pdb++ breakpoint for Recorder Mode) Language Options: --en / --English | --zh / --Chinese @@ -46,7 +46,7 @@ def invalid_run_command(msg=None): exp += " sbase mkfile new_test.py\n" exp += " Options:\n" exp += " -b / --basic (Basic boilerplate / single-line test)\n" - exp += " -r / --rec (adds ipdb breakpoint for Recorder Mode)\n" + exp += " -r / --rec (add pdb++ breakpoint for Recorder Mode)\n" exp += " Language Options:\n" exp += " --en / --English | --zh / --Chinese\n" exp += " --nl / --Dutch | --fr / --French\n" @@ -232,7 +232,7 @@ def main(): data.append(' self.open("%s")' % url) else: data.append(" if self.recorder_ext and not self.xvfb:") - data.append(" import ipdb; ipdb.set_trace()") + data.append(" import pdb; pdb.set_trace()") if not basic and not recorder: data.append( ' self.type("input", "%s")' " # selector, text" % goodbye diff --git a/seleniumbase/console_scripts/sb_mkrec.py b/seleniumbase/console_scripts/sb_mkrec.py index ca21d4b7..cd699172 100755 --- a/seleniumbase/console_scripts/sb_mkrec.py +++ b/seleniumbase/console_scripts/sb_mkrec.py @@ -172,7 +172,9 @@ def main(): data.append("class RecorderTests(BaseCase):") data.append(" def test_recording(self):") data.append(" if self.recorder_ext and not self.xvfb:") - data.append(" import ipdb; ipdb.set_trace()") + data.append(" # When you are done recording actions,") + data.append(' # type "c" and press [ENTER] to continue') + data.append(" import pdb; pdb.set_trace()") data.append("") file = codecs.open(file_path, "w+", "utf-8") file.writelines("\r\n".join(data)) diff --git a/seleniumbase/console_scripts/sb_recorder.py b/seleniumbase/console_scripts/sb_recorder.py index 6e082ff9..f6022256 100755 --- a/seleniumbase/console_scripts/sb_recorder.py +++ b/seleniumbase/console_scripts/sb_recorder.py @@ -279,7 +279,7 @@ def recorder_still_running(): def show_still_running_warning(): """Give the user a chance to end the recording safely via the - pytest ipdb Debug Mode so that processes such as chromedriver + pytest pdb Debug Mode so that processes such as chromedriver and Python don't remain open and hanging in the background.""" messagebox.showwarning( "SeleniumBase Recorder: Still Running!", diff --git a/seleniumbase/fixtures/base_case.py b/seleniumbase/fixtures/base_case.py index a6445020..10926a43 100755 --- a/seleniumbase/fixtures/base_case.py +++ b/seleniumbase/fixtures/base_case.py @@ -14050,16 +14050,16 @@ class BaseCase(unittest.TestCase): def __activate_behave_post_mortem_debug_mode(self): """Activate Post Mortem Debug Mode for failing tests that use Behave""" - import ipdb + import pdb - ipdb.post_mortem(sb_config.behave_step.exc_traceback) + pdb.post_mortem(sb_config.behave_step.exc_traceback) # Post Mortem Debug Mode ("behave -D pdb") def __activate_debug_mode_in_teardown(self): """Activate Debug Mode in tearDown() when using "--final-debug".""" - import ipdb + import pdb - ipdb.set_trace() + pdb.set_trace() # Final Debug Mode ("--final-debug") def has_exception(self): diff --git a/setup.cfg b/setup.cfg index f489a6aa..38a682c8 100755 --- a/setup.cfg +++ b/setup.cfg @@ -3,9 +3,6 @@ exclude=recordings,temp ignore=W503 -[ipdb] -context=5 - [nosetests] # nocapture=1 (Display print statements from output) # (Undo this by using: "--nologcapture")