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