kvas-it / pytest-console-scripts

Pytest plugin for testing console scripts
MIT License
78 stars 14 forks source link

console script subprocess calls are skipped #29

Open nick-youngblut opened 4 years ago

nick-youngblut commented 4 years ago

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.

kvas-it commented 4 years ago

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.