[Tutor] testing new style class properties using pyUnit ? (original) (raw)

Duncan Gibson duncan at thermal.esa.int
Thu Jul 1 04:40:42 EDT 2004


dyoo .at. hkn . eecs . berkeley . edu said:

Something strikes me weird though: if you're testing the set/get stuff, why not modify your test to:

def testSet(self): a = ANew() self.assertEqual(0, a.x) a.x = 1 self.assertEqual(1, a.x)

Yes, you are quite right: keep it simple, stupid!

In the actual original code I had the more contorted self.assertEqual(None, a.set_x(1)) because I wanted to do as much as possible within the pyUnit context and also because the original setter did a bit more behind the scenes than is obvious from this simplified example.

Cheers Duncan



More information about the Tutor mailing list