[pytest-dev] Testing of console scripts

Vasily Kuznetsov kvas.it at gmail.com
Thu Apr 28 09:21:16 EDT 2016


Thanks for the pointers, Florian.

The testdir fixture from pytest is pretty much what I was thinking about.
So if we could have a more generic version of it, wouldn't it be cool?

pytest-cram and cram in general looks quite neat, but I guess it doesn't
allow the second approach of running everything in the same python process,
which is an important feature for example for doing TDD.

Vasily



On Thu, Apr 28, 2016 at 2:11 PM Florian Bruhin <me at the-compiler.org> wrote:

> * Vasily Kuznetsov <kvas.it at gmail.com> [2016-04-28 11:55:48 +0000]:
> > I was recently writing some tests for a bunch of console scripts. I ended
> > up having a parametrised function that can run a script for real (using
> > subprocess.run) or can import its main function, mock the environment and
> > execute it in the same process (this is much faster).
>
> That's basically what pytest itself does with the pytester/testdir
> fixture too:
>
> https://github.com/pytest-dev/pytest/blob/master/_pytest/pytester.py
>
> > I've done similar things before and in general this seems to be a
> > reasonably common use case. I couldn't find a pytest plugin for testing
> > console scripts, so I'm wondering if it would be useful to create one.
> What
> > do you think?
>
> FWIW there's pytest-cram which has a totally different approach, but
> seemed quite interesting:
>
> https://github.com/tbekolay/pytest-cram
> https://bitheap.org/cram/
>
> Florian
>
> --
> http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
>    GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
>          I love long mails! | http://email.is-not-s.ms/
> _______________________________________________
> pytest-dev mailing list
> pytest-dev at python.org
> https://mail.python.org/mailman/listinfo/pytest-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20160428/51797150/attachment.html>


More information about the pytest-dev mailing list