from pyson.JsonValue import JsonValue, getJsonValue import unittest class JsoValueTest(unittest.TestCase): def testGetter(self): class Simple: @JsonValue() def getBla(self): return 1 simple=Simple() self.assertTrue(hasattr(simple.getBla, '__jsonvalue__')) self.assertTrue(getattr(simple.getBla, '__jsonvalue__')) f=getJsonValue(Simple) self.assertTrue(f) self.assertEqual(1, f(simple)) def testGetterWrongArity(self): self.assertRaises(ValueError, lambda: self.createClassWrongArity()) def createClassWrongArity(self): class Simple: @JsonValue() def getBla(self, x): return x