Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid interactive pdb when pytest tests itself - fix #2023 #2580

Merged
merged 1 commit into from
Jul 26, 2017

Conversation

andras-tim
Copy link
Contributor

@andras-tim andras-tim commented Jul 16, 2017

The debugging.py calls post_mortem() on error and pdb will drops an
interactive debugger when the stdin is a readable fd.

Thanks for submitting a PR, your contribution is really appreciated!

Here's a quick checklist that should be present in PRs:

  • Add a new news fragment into the changelog folder
    • name it $issue_id.$type for example (588.bug)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of removal, feature, bugfix, vendor, doc or trivial
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."
  • Target: for bugfix, vendor, doc or trivial fixes, target master; for removals or features target features;
  • Make sure to include reasonable tests for your change if necessary

Unless your change is a trivial or a documentation fix (e.g., a typo or reword of a small section) please:

  • Add yourself to AUTHORS;

@andras-tim andras-tim changed the title Avoid interactive pdb when pytest tests itself - fixed 2023 Avoid interactive pdb when pytest tests itself - fix 2023 Jul 16, 2017
@andras-tim andras-tim force-pushed the fix-runpytest-subprocess branch 2 times, most recently from 6843385 to f53a7c0 Compare July 16, 2017 12:30
@andras-tim andras-tim changed the title Avoid interactive pdb when pytest tests itself - fix 2023 Avoid interactive pdb when pytest tests itself - fix #2023 Jul 16, 2017
@andras-tim
Copy link
Contributor Author

And you can add the EP2017 sprint tag to this pull request 😉

@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.128% when pulling f53a7c0 on andras-tim:fix-runpytest-subprocess into 3578f4e on pytest-dev:master.

@andras-tim andras-tim force-pushed the fix-runpytest-subprocess branch from f53a7c0 to e5853ff Compare July 16, 2017 23:15
@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.128% when pulling e5853ff on andras-tim:fix-runpytest-subprocess into 3578f4e on pytest-dev:master.

@andras-tim andras-tim force-pushed the fix-runpytest-subprocess branch from e5853ff to f588238 Compare July 17, 2017 00:09
@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 92.13% when pulling f588238 on andras-tim:fix-runpytest-subprocess into 3578f4e on pytest-dev:master.

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

Thanks! I did test it locally and it does work as advertised. 👍

@nicoddemus
Copy link
Member

@RonnyPfannschmidt would you like to take a better look or can we merge this?

Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

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

overall this looks good, i#l approve after my question is resolved

return subprocess.Popen(cmdargs,
stdout=stdout, stderr=stderr, **kw)

popen = subprocess.Popen(cmdargs, stdin=subprocess.PIPE, stdout=stdout, stderr=stderr, **kw)
Copy link
Member

Choose a reason for hiding this comment

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

why PIPE when the message says DEVNULL ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, you are right. The original solution was subprocess.DEVNULL as stdin, but this was not available in older python version. Therefore I replaced it with a closed pipe, but I forgot to change the commit message too.

Copy link
Member

Choose a reason for hiding this comment

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

nitpick, please add a comment to switch to DEVNULL once we drop python2.6 support

Copy link
Member

Choose a reason for hiding this comment

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

subprocess.DEVNULL only was added in 3.3, but you can open os.devnull (which is a filename) before that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RonnyPfannschmidt, I think, the final solution with the closed pipe is much better than the original, because this is tinier.

In other hands, the DEVNULL solution opened an unnecessary fd, but we wanted to make a not interactive pdb only.

@andras-tim andras-tim force-pushed the fix-runpytest-subprocess branch from f588238 to 7d8ff55 Compare July 21, 2017 19:27
The debugging.py calls post_mortem() on error and pdb will drops an
interactive debugger when the stdin is a readable fd.
@andras-tim andras-tim force-pushed the fix-runpytest-subprocess branch from 7d8ff55 to 50764d9 Compare July 21, 2017 19:30
@andras-tim
Copy link
Contributor Author

I updated the changelog and rebased to upstream master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 92.095% when pulling 50764d9 on andras-tim:fix-runpytest-subprocess into 1cf8266 on pytest-dev:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 92.095% when pulling 50764d9 on andras-tim:fix-runpytest-subprocess into 1cf8266 on pytest-dev:master.

@nicoddemus
Copy link
Member

If anybody else needs more time to take a further look let me know, otherwise I plan to merge this tomorrow.

@nicoddemus nicoddemus merged commit 2c2cf81 into pytest-dev:master Jul 26, 2017
@nicoddemus
Copy link
Member

Thanks again @andras-tim!

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.

5 participants