[BangPypers] Favorite tips/techniques
Saager Mhatre
saager.mhatre at gmail.com
Fri Sep 13 09:56:31 CEST 2013
On Sep 9, 2013 8:51 PM, "CsquaredinOmaha" <c2inomaha at yahoo.com> wrote:
>
>
> For a while I had thought it would be interesting to hear
"tips/techniques you
> find yourself often using" - or perhaps found useful at one point (and
thus would be valuable to newbies).
>
> It could be simple snippet, or some description of logic, technique or
steps.
> From simple to sophisticated is less the issue - more that you "found it
handy and used it alot".
>
> Whatever use area: ETL data files, servers, SQL maintenance,
webcrawlers, anything.
== Writing tests as top-level functions as opposed to methods of a
unittest.TestCase subclass ==
Aside from the obvious advantage of eliminating ceremony, this has the
effect of forcing me to make sure that each test is entirely and atomically
independent of other tests. That way, I only ever have to read one function
to understand the nature of a given test failure.
Also, not having the ability to easily slap on setup/teardown
functions/methods forces me to make tests self-contained. Add in the
heuristic that tests with long/complicated arrange and/or act sections are
indicative of potential design flaws and you have the requisite TDD
feedback.
It also helps tremendously that both nosetest and pytest support this idiom.
- d
More information about the BangPypers
mailing list