Skip to content

Allow passing a custom Pdb subclass via --pdbcls. - #1712

Merged
RonnyPfannschmidt merged 2 commits into
pytest-dev:featuresfrom
anntzer:custom-debugger
Jul 12, 2016
Merged

RonnyPfannschmidt merged 2 commits into
pytest-dev:featuresfrom
anntzer:custom-debugger

Conversation

@anntzer

@anntzer anntzer commented Jul 10, 2016 •

Copy link
Copy Markdown
Contributor

This obviates the need for plugins such as pytest-ipdb; instead one can simply call py.test --pdbcls=IPython.core.debugger:Pdb

A test is missing, advice as to how to best implement one would be appreciated.

This obviates the need for plugins such as `pytest-ipdb`; instead one
can simply call `py.test --pdb=IPython.core.debugger:Pdb`
@coveralls

coveralls commented Jul 10, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.03%) to 92.118% when pulling 6383b53 on anntzer:custom-debugger into 7a2058e on pytest-dev:features.

@nicoddemus

Copy link
Copy Markdown
Member

Hi @anntzer thanks for the PR!

To implement this test, I suggest implementing a dummy debugger class inside the test function and ensuring that it gets instantiated.

Comment thread CHANGELOG.rst Outdated
giving no clue about the actual reason for double-added options.

*
* Allow passing a custom debugger class (e.g. ``IPython.core.debugger:Pdb``

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go into "New Features" and please include a "Thanks @anntzer for the PR" message 😉

@anntzer

anntzer commented Jul 12, 2016

Copy link
Copy Markdown
Contributor Author

The tests are failing due to "reading from stdin while output is captured" even though this does not seem to occur when manually trying the new feature... any chance you can help me there?

Comment thread _pytest/debugging.py Outdated
help="start the interactive Python debugger on errors.")
group._addoption(
'--pdbcls', dest="usepdb_cls", metavar="modulename:classname",
help="start a custom interactive Python debugger on errors.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can add your example here:

help="start a custom interactive Python debugger on errors."
     "For example: --pdbcls=IPython.core.debugger:Pdb"         

@nicoddemus

Copy link
Copy Markdown
Member

Aside from my comments this looks good to me! 😁

@nicoddemus

Copy link
Copy Markdown
Member

The tests are failing due to "reading from stdin while output is captured" even though this does not seem to occur when manually trying the new feature... any chance you can help me there?

Sure, I will try your branch in a bit.

@nicoddemus

Copy link
Copy Markdown
Member

@anntzer please check this commit on my fork. That fixes your test.

The problem is that by using a pdb subclass we end up trying to read from the stdin inside the test, but because the input is being captured by pytest itself to later test stdout, it fails. My approach is to install a dummy class and made sure some of its methods were called, which is what we're interested in anyway.

Feel free to cherry-pick that commit into your branch.

@anntzer

anntzer commented Jul 12, 2016

Copy link
Copy Markdown
Contributor Author

done.

@coveralls

coveralls commented Jul 12, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.06%) to 92.22% when pulling 7c96a65 on anntzer:custom-debugger into 6f68dfc on pytest-dev:features.

Comment thread CHANGELOG.rst Outdated

*
* Allow passing a custom debugger class (e.g. ``IPython.core.debugger:Pdb``
via ``--pdbcls``. Thanks to `@anntzer`_ for the PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add a reference to anntzer down below, otherwise linting will fail.

Also, we should have a closing parenthesis after --pdbcls here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@nicoddemus

Copy link
Copy Markdown
Member

Thanks! There's a minor adjustment needed to the CHANGELOG, other than that I think this looks good.

(and edit CHANGELOG)
@coveralls

coveralls commented Jul 12, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.06%) to 92.22% when pulling 7ee3dd1 on anntzer:custom-debugger into 6f68dfc on pytest-dev:features.

@RonnyPfannschmidt

Copy link
Copy Markdown
Member

good to merge?

@nicoddemus

Copy link
Copy Markdown
Member

IMHO yes, please do it if you don't have other comments on it. 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants