import unittest from main import Object, asdict, recursive_asdict # Update based on your main.py structure if __name__ == "__main__": import testutils testutils.run_using_pytest(globals()) class TestSudsFunctions(unittest.TestCase): def test_asdict(self): # Create an Object sobject = Object() sobject.name = "John Doe" sobject.age = 30 sobject.children = [] # Call the asdict function result = asdict(sobject) # Assert the expected result expected = { 'name': 'John Doe', 'age': 30, 'children': [] } self.assertEqual(result, expected) def test_recursive_asdict(self): # Create an Object with nested objects outer_object = Object() outer_object.name = "John Doe" outer_object.age = 30 outer_object.children = [] inner_object = Object() inner_object.name = "Jane Doe" inner_object.age = 25 inner_object.children = [] outer_object.children.append(inner_object) grandchild_object = Object() grandchild_object.name = "Baby Doe" grandchild_object.age = 1 inner_object.children.append(grandchild_object) # Call the recursive_asdict function result = recursive_asdict(outer_object, True) # Assert the expected result expected = { 'name': 'John Doe', 'age': 30, 'children': [ { 'name': 'Jane Doe', 'age': 25, 'children': [ { 'name': 'Baby Doe', 'age': 1 } ] } ] } self.assertEqual(result, expected) if __name__ == "__main__": unittest.main()