import unittest from pyson.JsonTools import getInitArgs, getListClass from abc import ABC from pyson.JsonSubTypes import JsonSubTypes class JsonToolsTest(unittest.TestCase): def testGetInitArgs(self): class ClassWithInitVars: def __init__(self, x:int): y=2 self.assertEquals({"x":int}, getInitArgs(ClassWithInitVars)) def testGetInitArgsAbc(self): class BaseClass(ABC): pass class ClassWithInitVars2(BaseClass): def __init__(self, x:int): y=2 self.assertEquals({"x":int}, getInitArgs(ClassWithInitVars2)) def testGetListTypePrimitiveMixed(self): self.assertEqual(None, getListClass([3, True])) def testGetListTypePolymorphicNMixed(self): class A: pass class B(A): pass self.assertRaises(ValueError, lambda:getListClass([A(),B()]))