From 400e37c56c9772fdc4c04ddb29d8a4a20568fb1a Mon Sep 17 00:00:00 2001 From: Wes Turner <50891+westurner@users.noreply.github.com> Date: Wed, 2 Aug 2023 21:00:25 -0400 Subject: [PATCH] DOC: README.rst: note about pytest support - https://stackoverflow.com/questions/39162569/use-ipdb-instead-of-pdb-with-py-test-pdb-option - https://docs.pytest.org/en/stable/reference/customize.html --- README.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.rst b/README.rst index 1c96164..dbfff79 100644 --- a/README.rst +++ b/README.rst @@ -191,3 +191,33 @@ instead of ``pdb``. (It does not depend on ``ipdb`` anymore). .. _ipdbplugin: http://pypi.python.org/pypi/ipdbplugin .. _nose: http://readthedocs.org/docs/nose + + +pytest ++++++++ +pytest_ supports a ``--pdb`` option which can run ``ipdb`` / +``IPython.terminal.debugger:Pdb`` on ``Exception`` and ``breakpoint()``: + +.. code:: bash + + pytest --pdb --pdbcls=IPython.terminal.debugger:Pdb -v ./test_example.py + +You don't need to specify ``--pdbcls`` for every ``pytest`` invocation +if you add ``addopts`` to ``pytest.ini`` or ``pyproject.toml``. + +``pytest.ini``: + +.. code:: bash + + [tool.pytest.ini_options] + addopts = "--pdbcls=IPython.terminal.debugger:Pdb" + +``pyproject.toml``: + +.. code:: yml + + [tool.pytest.ini_options] + addopts = "--pdbcls=IPython.terminal.debugger:Pdb" + + +.. _pytest: https://pypi.python.org/pypi/pytest