[CentralOH] Not So Strange Class Behavior

jep200404 at columbus.rr.com jep200404 at columbus.rr.com
Thu Feb 6 16:46:00 CET 2014

On Thu, 6 Feb 2014 09:54:55 -0500, Joshua Kramer <joskra42.list at gmail.com> wrote:

> I'm writing a testing utility.  

Reinventing the wheel for fun? 

> I have an odd problem with properly
> dereferencing objects within a class. 

> 1. A file called sql_cases.py, with this:

> global TEST_CASES


> class Test090Case1:

> TEST_CASES['Test090Case1'] = Test090Case1

> def Main():
>     th = TestHarness()
>     for tc in TEST_CASES.keys():
>         th.setUp(tc)

Note that tc is a string. 
Did you mean th.setup(TEST_CASES[tc]) or 
for tc in TEST_CASES.values():?

> What am I doing wrong here?

It started with class versus instance object confusion. 
I don't know if you meant to use instance methods or 
class methods. Study class methods: @classmethod decorator 
and self versus cls. Don't stop at one bug. 
Bring them to the dojo. 


More information about the CentralOH mailing list