473,395 Members | 1,688 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,395 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 1288

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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.