import requests as req class CreateItemChecks: def createAuthor (result): return 'response' in result class CreateItemActions: def createAuthor (): return req.post( "http://127.0.0.1:8080/api/v/1.0/create-item?response_format=json", json={ "type" : "author" } ).json() createItemActions = CreateItemActions() createItemChecks = CreateItemChecks() def test (id, action, isDone): try: print("""Test {id} runned..""") result = action() if isDone(result): print("""Test {id} success!""") else: print("""Test {id} ERROR""") print(result) except Exception as exc: print(exc) test(1, createItemActions.createAuthor, createItemChecks.createAuthor)