pytest-console-scripts icon indicating copy to clipboard operation
pytest-console-scripts copied to clipboard

console script subprocess calls are skipped

Open nick-youngblut opened this issue 5 years ago • 1 comments

I am trying to test a console script that itself runs calls subprocess a few times in the script. These subprocess calls are just skipped when using pytest-console-scripts-0.2.0. The rest of the console script, but it simply bypasses the subprocess calls. I don't see anything about this in the pytest-console-scripts docs.

nick-youngblut avatar Feb 26 '20 09:02 nick-youngblut

I tried to reproduce this with the following test:

@pytest.mark.script_launch_mode('both')
def test_subprocess(console_script, script_runner):
    console_script.write(
        """
import subprocess
res = subprocess.run(['echo', 'foo'], stdout=subprocess.PIPE)
print(res.returncode)
print(res.stdout.decode('utf-8'))
        """
    )
    result = script_runner.run(str(console_script))
    assert result.success
    assert result.stdout == '0\nfoo\n\n'

It passes, as expected. Can you construct an example of your behavior please, then I could investigate further.

kvas-it avatar Sep 01 '20 20:09 kvas-it