[pytest-dev] Testing of console scripts

Vasily Kuznetsov kvas.it at gmail.com
Thu Apr 28 16:45:23 EDT 2016


Yeah, this is exactly what I had in mind (articulated in more detail than I
had in mind :).
I think I'll put some code together when I have a bit of time and then we
can see.

Thank you,
Vasily

On Thu, Apr 28, 2016 at 6:35 PM Bruno Oliveira <nicoddemus at gmail.com> wrote:

> On Thu, Apr 28, 2016 at 1:20 PM Vasily Kuznetsov <kvas.it at gmail.com>
> wrote:
>
>> Yes, exactly, I want to do both (in-process and subprocess). So while I'm
>> hacking on the new features I'd run in-process for speed and then I'd use
>> something like tox to run proper subprocess tests in different
>> environments. And those would be the same tests, I'd just change some
>> configuration setting to switch between the two approaches.
>>
>> And there are indeed limitations to the in-process approach, like the one
>> you described, so perhaps it would be useful to be able to override the
>> config setting in particular tests that don't work with it.
>>
>
> Having a command line option that can change between the two approaches
> sounds good, as well as having a mark to always enforce it for a particular
> test:
>
> py.test --script-launch-mode=subprocess
> py.test --script-launch-mode=inprocess
>
> @pytest.mark.script_launch_mode('subprocess')
> def test_foo(script_tester):
>     result = script_tester.run('script --args')
>     assert result.success
>     result.stdout.fnmatch_lines(...)
>
> In your CI server you can choose to run your test suite twice to ensure
> both modes are working as expected in your test suite. Also, to avoid
> taking twice as long, the plugin could also automatically mark tests which
> use the fixture so the second run can execute only those tests.
>
> I definitely would like to see a plugin that implements something like
> this. :)
>
> Cheers,
>
> Bruno.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20160428/0d9b8077/attachment.html>


More information about the pytest-dev mailing list