Propagating poorly chosen idioms

S

Skip Montanaro

Peter> unitttest is surely not the be all and end all of Python unit
Peter> testing frameworks... but it's one of the batteries included in
Peter> the standard distribution, and it's pretty trivial to get started
Peter> using it, unless maybe you try to go by the documentation instead
Peter> of by the examples...

This reminded me of something I noticed awhile ago. If you're learning
something new, there is a tendency to find a working example to start from,
then modify it to suit your needs. This is fine as far as it goes, however,
if the idioms used in the code you're cloning are suboptimal, they get
cloned.

Unittest's API is difficult enough for me to remember (at least the initial
framework I need to put together) that I generally hunt down some previous
unittest usage, clone it and start from there. I no longer have any idea
what the original unittest example was that got me started using it in the
first place (probably something in the distro's docs). I can only hope it
was a good example.
From that standpoint the simpler API of py.test seems attractive.

Skip
 
S

Steven Bethard

Skip said:
Unittest's API is difficult enough for me to remember (at least the initial
framework I need to put together) that I generally hunt down some previous
unittest usage, clone it and start from there. I no longer have any idea
what the original unittest example was that got me started using it in the
first place (probably something in the distro's docs). I can only hope it
was a good example.

That's a really good point. I do the exact same thing. It's not like
Unittest is all that complicated, but it's just complicated enough that
I can't remember all the details when I want to write a new one... I've
been putting off looking into py.test for a while, but maybe I need to
finally do so...

STeVe
 
R

Raymond Hettinger

[Skip Montanaro]
This reminded me of something I noticed awhile ago. If you're learning
something new, there is a tendency to find a working example to start from,
then modify it to suit your needs. This is fine as far as it goes, however,
if the idioms used in the code you're cloning are suboptimal, they get
cloned.

Unittest's API is difficult enough for me to remember (at least the initial
framework I need to put together) that I generally hunt down some previous
unittest usage, clone it and start from there. I no longer have any idea
what the original unittest example was that got me started using it in the
first place (probably something in the distro's docs). I can only hope it
was a good example.

If it was the distro or tutorial example, I hope you thought it was good.

I added those examples to the docs with the intention facilitating
cut-and-paste jobs so folks could get up and running quickly.

The remainder of the unittest docs are somewhat obtuse and uninspiring.



That is their number one selling point. I hope they don't lose it as the
package evolves to include doctests and such.



Raymond Hettinger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,234
Messages
2,571,178
Members
47,808
Latest member
sunnysingh55

Latest Threads

Top