Skip to content

Commit a6822e9

Browse files
committed
Replace "ipdb" with an upgraded "pdb" debugger
1 parent 842deb6 commit a6822e9

File tree

16 files changed

+53
-42
lines changed

16 files changed

+53
-42
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ pytest my_first_test.py --demo
451451
452452
```python
453453
import time; time.sleep(5) # Makes the test wait and do nothing for 5 seconds.
454-
import ipdb; ipdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
454+
import pdb; pdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
455455
import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
456456
```
457457
@@ -461,7 +461,7 @@ import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continu
461461
pytest my_first_test.py --pdb
462462
```
463463
464-
(**``ipdb``** console commands: ``n``, ``c``, ``s`` => ``next``, ``continue``, ``step``).
464+
(**``pdb``** console commands: ``n``, ``c``, ``s`` => ``next``, ``continue``, ``step``).
465465
466466
<a id="pytest_options"></a>
467467
🔵 Here are some useful command-line options that come with <code>pytest</code>:

examples/master_qa/pytest.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[pytest]
22

3-
# Display console output, disable cacheprovider, and have the ipdb debugger replace pdb:
4-
addopts = --capture=no -p no:cacheprovider --pdbcls=IPython.terminal.debugger:TerminalPdb
3+
# Display console output, disable cacheprovider:
4+
addopts = --capture=no -p no:cacheprovider
55

66
# Ignore warnings such as DeprecationWarning and PytestUnknownMarkWarning
77
filterwarnings =

examples/migration/raw_selenium/pytest.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[pytest]
22

3-
# Display console output, disable cacheprovider, and have the ipdb debugger replace pdb:
4-
addopts = --capture=no -p no:cacheprovider --pdbcls=IPython.terminal.debugger:TerminalPdb
3+
# Display console output, disable cacheprovider:
4+
addopts = --capture=no -p no:cacheprovider
55

66
# Ignore warnings such as DeprecationWarning and PytestUnknownMarkWarning
77
filterwarnings =

examples/translations/pytest.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[pytest]
22

3-
# Display console output, disable cacheprovider, and have the ipdb debugger replace pdb:
4-
addopts = --capture=no -p no:cacheprovider --pdbcls=IPython.terminal.debugger:TerminalPdb
3+
# Display console output, disable cacheprovider:
4+
addopts = --capture=no -p no:cacheprovider
55

66
# Ignore warnings such as DeprecationWarning and PytestUnknownMarkWarning
77
filterwarnings =

help_docs/chinese.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,11 @@ pytest --collect-only -q
325325
```
326326

327327
您可以在脚本中使用以下内容来帮助您调试问题:
328-
(<i>如果使用ipdb,请确保将“-s”添加到命令行选项中,除非已经在pytest.ini中</i>)
328+
(<i>如果使用pdb,请确保将“-s”添加到命令行选项中,除非已经在pytest.ini中</i>)
329329

330330
```python
331331
import time; time.sleep(5) # Makes the test wait and do nothing for 5 seconds.
332-
import ipdb; ipdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
332+
import pdb; pdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
333333
import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
334334
```
335335

@@ -339,7 +339,7 @@ import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continu
339339
pytest my_first_test.py --pdb -s
340340
```
341341

342-
上面的代码将在出现故障时打开浏览器窗口。(ipdb命令:'n', 'c', 's' => next, continue, step)。
342+
上面的代码将在出现故障时打开浏览器窗口。(pdb命令:'n', 'c', 's' => next, continue, step)。
343343

344344
下面是Pytest附带的一些有用的命令行选项:
345345

help_docs/customizing_test_runs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ You can use the following calls in your scripts to help you debug issues:
250250

251251
```python
252252
import time; time.sleep(5) # Makes the test wait and do nothing for 5 seconds.
253-
import ipdb; ipdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
253+
import pdb; pdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
254254
import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
255255
```
256256

@@ -260,7 +260,7 @@ To pause an active test that throws an exception or error, add ``--pdb -s``:
260260
pytest my_first_test.py --pdb -s
261261
```
262262

263-
The code above will leave your browser window open in case there's a failure. (ipdb commands: 'c', 's', 'n' => continue, step, next).
263+
The code above will leave your browser window open in case there's a failure. (pdb commands: 'c', 's', 'n' => continue, step, next).
264264

265265
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Combinations of options:</h3>
266266

help_docs/recorder_mode.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,20 @@ sbase mkrec new_test.py --url=wikipedia.org
2626

2727
pytest new_test.py --rec -q -s --url=wikipedia.org
2828

29-
> .../SeleniumBase/examples/new_test.py(7)test_recording()
30-
5 def test_recording(self):
31-
6 if self.recorder_ext and not self.xvfb:
32-
----> 7 import ipdb; ipdb.set_trace()
29+
>>>>>>>>>>>>>>>>>> PDB set_trace >>>>>>>>>>>>>>>>>
3330

34-
ipdb> c
31+
-> import pdb; pdb.set_trace()
32+
> .../YOUR_CURRENT_DIRECTORY/new_test.py(9)
33+
34+
5 def test_recording(self):
35+
6 if self.recorder_ext and not self.xvfb:
36+
7 # When you are done recording actions,
37+
8 # type "c" and press [ENTER] to continue
38+
9 -> import pdb; pdb.set_trace()
39+
return None
40+
(Pdb++) c
41+
42+
>>>>>>>>>>>>>>>>>> PDB continue >>>>>>>>>>>>>>>>>>
3543

3644
>>> RECORDING SAVED as: recordings/new_test_rec.py
3745
**************************************************
@@ -71,7 +79,7 @@ The first command creates a boilerplate test with a breakpoint; the second comma
7179
⏺️ 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:
7280
7381
```python
74-
import ipdb; ipdb.set_trace()
82+
import pdb; pdb.set_trace()
7583
```
7684
7785
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
8088
pytest TEST_NAME.py --rec -s
8189
```
8290
83-
⏺️ 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.)
91+
⏺️ 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.)
8492
8593
```bash
8694
pytest TEST_NAME.py --trace --rec -s

pytest.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[pytest]
22

3-
# Display console output, disable cacheprovider, and have the ipdb debugger replace pdb:
4-
addopts = --capture=no -p no:cacheprovider --pdbcls=IPython.terminal.debugger:TerminalPdb
3+
# Display console output, disable cacheprovider:
4+
addopts = --capture=no -p no:cacheprovider
55

66
# Ignore warnings such as DeprecationWarning and PytestUnknownMarkWarning
77
filterwarnings =

seleniumbase/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import collections
2+
import pdb
23
import sys
34
from selenium import webdriver
45
from seleniumbase.__version__ import __version__
@@ -14,6 +15,15 @@
1415
from seleniumbase.plugins.driver_manager import Driver # noqa
1516
from seleniumbase.plugins.driver_manager import DriverContext # noqa
1617

18+
if hasattr(pdb, "DefaultConfig"):
19+
# Only load pdbpp configuration if pdbpp is installed
20+
pdb.DefaultConfig.filename_color = pdb.Color.blue
21+
pdb.DefaultConfig.line_number_color = pdb.Color.turquoise
22+
pdb.DefaultConfig.show_hidden_frames_count = False
23+
pdb.DefaultConfig.disable_pytest_capturing = True
24+
pdb.DefaultConfig.enable_hidden_frames = False
25+
pdb.DefaultConfig.truncate_long_lines = True
26+
pdb.DefaultConfig.sticky_by_default = True
1727
if sys.version_info[0] >= 3:
1828
from seleniumbase import translate # noqa
1929
if sys.version_info >= (3, 7):

seleniumbase/console_scripts/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def show_mkfile_usage():
259259
print(" sbase mkfile new_test.py")
260260
print(" Options:")
261261
print(" -b / --basic (Basic boilerplate / single-line test)")
262-
print(" -r / --rec (adds ipdb breakpoint for Recorder Mode)")
262+
print(" -r / --rec (add pdb++ breakpoint for Recorder Mode)")
263263
print(" Language Options:")
264264
print(" --en / --English | --zh / --Chinese")
265265
print(" --nl / --Dutch | --fr / --French")

0 commit comments

Comments
 (0)