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

How to hide output while using the pattern option #88

Open
patrick91 opened this issue Feb 23, 2022 · 1 comment
Open

How to hide output while using the pattern option #88

patrick91 opened this issue Feb 23, 2022 · 1 comment
Labels

Comments

@patrick91
Copy link

Is there a way to hide all the ouput while using the pattern option? I've tried this:

class Starter(ProcessStarter):
    env = {"PYTHONUNBUFFERED": "1", **os.environ}
    pattern = BOOT_MSG
    popen_kwargs = {
        "stdout": subprocess.DEVNULL,
        "stderr": subprocess.STDOUT,
    }

but it breaks the pattern check :)

@northernSage
Copy link
Member

Hey @patrick91. Yes, the code shown would naturally break pattern matching since you are effectively throwing away all process output so xprocess has nothing to match your pattern against. What output, specifically, would like to hide? Are you referring to pytest output? The output of the initialized process should be captured by pytest and should not show under normal circumstances (unless you disable all capture with -s flag). You can further customize pytest capturing with:

pytest -s                  # disable all capturing
pytest --capture=sys       # replace sys.stdout/stderr with in-mem files
pytest --capture=fd        # also point filedescriptors 1 and 2 to temp file
pytest --capture=tee-sys   # combines 'sys' and '-s', capturing sys.stdout/stderr
                           # and passing it along to the actual sys.stdout/stderr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants