pytest-dev / pytest-dev/pytest
capsys.disabled for stdin
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
I'm using pytest 3.0.4
Currently, using capsys.disabled prevents the capturing on stdout. But it does not do anything for stdin, which is also important for my use. (specifically, I want to be able to use input().)
Adding the -s command line option works, but I'd like to do it programmatically in a test. Ideally, you'd get something like this:
def test_capfd_thing(capfd):
print("this won't be visible")
with capsys.disabled():
print("this will be visible.")
s = input("Type the word potato:")
print("you said: "+ s)
assert 'potato' in s
I'm not sure whether only disabling the capturing of stdout is expected behavior (in which case I would like a way to do what I'm doing above) or a bug.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the capsys.disabled entry point and the -s command-line behavior described in the issue, then inspect the capture implementation and related tests. Verify how stdin is handled while stdout capture is disabled; done means a test can use input() interactively inside the context while normal capture remains unchanged outside it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100