By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,773 Members | 1,838 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,773 IT Pros & Developers. It's quick & easy.

Smart dummy objects

P: n/a
I'd appreciate comments on what I'm doing.

Please be kind, I'm a new kid on the block.
Here's my application.

I'm writing some test code.

(I'm a recent convert to unit testing.)
I want to test a series of changes to an object.

The change methods return self, so I can form chains.

Like so:
x = obj.this().that(12).other(x=3, y=12)
assert x is obj
A Dummy class (easily coded) allows:
d = Dummy()
y = d.this().that(12).other(x=3, y=12)
assert y is d
to execute without errors.

Function calls (and getting attributes) do not change d.

And these operations return self.
I'm looking for a SmartDummy class.

So that:
sd = SmartDummy()
sd.this.that(12).other(x=3, y=12)
assert z is sd
always executes without errors (it's a Dummy) ...
.... and because it's a SmartDummy,
magic = sd.special_method_name(obj)
is equivalent to
magic = obj.this().that(12).other(x=3, y=12)
even to the raising of exceptions.
This allows a chain of changes to be stored in a SmartDummy.

And then applied to a succession of real objects.
Before writing much code, I did a google for "SmartDummy" and "smart
dummy" in this newsgroup.

I got no hits, which discouraged me.

I then searched all newsgroups. Got 24 and 39,200 hits resp.

http://groups.google.com/groups?hl=en&lr=&q=SmartDummy
http://groups.google.com/groups?hl=e...G=Search&meta=

The 24 were not helpful, the 39,200 too many.
A search of the web for SmartDummy was not helpful.
http://www.google.com/search?hl=en&lr=&q=SmartDummy
But "Smart Dummy" was.
http://www.google.com/search?q=Smart...r=&sa=N&tab=gw

The very first hit was:
http://www.tc.gc.ca/mediaroom/releas...4/04-h082e.htm

It announced the Canadian debut of:
===
WorldSID (World Side Impact Dummy) was born out of a need to have a
world harmonized crash test dummy that would better simulate the motions
of a human in side impact crash testing.
===
This encouraged me. Smart Dummies are important. They can save lives.

Maybe they are a good idea. Let's try to make a Python SmartDummy.

So I went ahead and spend the morning coding up my SmartDummy class.
Much of it is now working, but it's not yet ready for its Python debut.

Hope this of interest.
BTW, I'm a bit of a Python newbie, particularly regarding culture.

This is my first post to comp.lang.python. (I was a lurker.)

However, I am a regular on comp.text.tex.
As I said, I'd appreciate your comments on this.
Jonathan

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.