[TIP] shell-like tests

Martin Pool mbp at sourcefrog.net
Mon Jun 17 14:58:00 PDT 2013


Thanks for mentioning those two. On a brief read the differences seem to be:

- Cram runs test scripts located in separate files, and can patch them with
the differences, which would make it great for testing documentation
examples, and maybe a bit harder if you want to run some Python setup or
mocking code around the code under test.

- ScriptTest returns the output etc from the command for the test to
examine, whereas shelliketests and cram automatically diff it against
expected output.


On 18 June 2013 00:36, Chris Wesseling <Chris.Wesseling at cwi.nl> wrote:

> On 2013-06-17T11:12:58+0200, Pierre-Yves David wrote:
> > On Mon, Jun 17, 2013 at 06:34:42AM +1000, Martin Pool wrote:
> > > I have just extracted the 'shell-like tests' library from bzr's test
> > > library.  example:
> > >
> > >     def test_echo(self):
> > >         run_script(self, """
> > >             $ echo hello world
> > >             hello world
> > >             """)
> > >
> > > This library makes it easy to write integration tests for programs
> with a
> > > command-line interface: you just give the command and the expected
> output.
> > > The command can be run as an in-process Python call, to let you
> precisely
> > > control its environment through mocks etc. This style also makes it
> pretty
> > > easy for new contributors to add tests.
> > >
> > > https://github.com/sourcefrog/shellliketests
> >
> > On similar topic, the Mercurial sell-like tests tools have been
> extracted as "cram"
> >
> >     https://bitheap.org/cram/
> >
> > I never tested the bzr one so I have no idea how they compare to each
> other.
>
> I've been using Ian Bicking's ScriptTest library for that. And this
> weekend I learned that it's what the pip project is using too.
>
> It's on pypi.
>
> --
> Chris Wesseling
> Centrum Wiskunde & Informatica (CWI)
> https://www.cwi.nl/people/ccw
>



-- 
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20130618/2f5e200a/attachment.htm>


More information about the testing-in-python mailing list