Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #24870
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: adding a simulation mode |
| References | <mailman.1786.1341394979.4697.python-list@python.org> |
| Date | 2012-07-04 10:01 -0700 |
| Message-ID | <7x7guj4g03.fsf@ruckus.brouhaha.com> (permalink) |
| Organization | Nightsong/Fort GNOX |
andrea crotti <andrea.crotti.0@gmail.com> writes:
> copytree(src, dest) becomes:
> if not PRETEND_ONLY:
> copytree(src, dest)
>
> But I don't like it too much because I would have to add a lot of
> garbage around..
I've had good results writing the module under test in the style of a
java applet, i.e. one of its args is a class instance representing the
"outside world", and ALL interaction that you might want to simulate is
done through this object:
def your_prog(parent):
conn = parent.db.make_connection(...)
blah = parent.copytree(...)
Then you make "real" and "mock" versions of the external interface, and
pass in an appropriate instance.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
adding a simulation mode andrea crotti <andrea.crotti.0@gmail.com> - 2012-07-04 10:42 +0100
Re: adding a simulation mode Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-04 13:41 +0000
Re: adding a simulation mode andrea crotti <andrea.crotti.0@gmail.com> - 2012-07-04 14:59 +0100
Re: adding a simulation mode andrea crotti <andrea.crotti.0@gmail.com> - 2012-07-04 15:19 +0100
Re: adding a simulation mode Paul Rubin <no.email@nospam.invalid> - 2012-07-04 10:01 -0700
csiph-web