[TIP] shell-like tests
marius at gedmin.as
Thu Jun 20 09:18:01 PDT 2013
On Mon, Jun 17, 2013 at 04:36:30PM +0200, Chris Wesseling 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.
And while we're enumerating other tools that can do this, one of them is
with the interpretation of 'sh>' defined in
Okay, now that I look at that
transform=lambda s: 'system("%s")\n' % s.rstrip()
I'm a little bit scared.
<phrakture> i learned vim by reading the source code. am I hardcore yet?
<Axioplase> phrakture: not enought yet... read it rot13'd, and you'll be
<phrakture> I read it as analog output on an oscilliscope
<mgedmin> rot13, bah, try reading the gzipped source tarball
<lack> standing on your head.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 190 bytes
Desc: Digital signature
More information about the testing-in-python