473,287 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Smart dummy objects

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
0 1282

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Susan Baker | last post by:
Hi, I'm just reading about smart pointers.. I have some existing C code that I would like to provide wrapper classes for. Specifically, I would like to provide wrappers for two stucts defined...
6
by: Shankar | last post by:
Hello, We have a smart pointer class which provides the dereference operator -> to access the underlying object pointer. Now, we have a new requirement where a different type of object (e.g from...
16
by: Yong Hu | last post by:
Does the smart pointer never lead to memory leak? Thanks,
92
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers,...
14
by: Ian | last post by:
I am looking at porting code from a C++ application to C#. This requires implementing data sharing functionality similar to what is provided by a smart pointer in C++. I have only recently begun...
33
by: Ney André de Mello Zunino | last post by:
Hello. I have written a simple reference-counting smart pointer class template called RefCountPtr<T>. It works in conjunction with another class, ReferenceCountable, which is responsible for the...
3
by: Nindi73 | last post by:
Hi, I am in need of a deep copy smart pointer (Boost doesn't provide one) which doesnt require the contained types to have a virtual copy constructor. I wrote a smart pointer class that I think...
11
by: Nindi73 | last post by:
A few days a ago I posted my code for a deep copy pointer which doesn't require the pointee object to have a virtual copy constructor. I need help with checking that it was exception safe and...
54
by: Boris | last post by:
I had a 3 hours meeting today with some fellow programmers that are partly not convinced about using smart pointers in C++. Their main concern is a possible performance impact. I've been explaining...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.