What parameters are missing when I use this function? Python, Pytest

55 Views Asked by At

I am trying to call a function to use it result in parametrize. I use fixtures in this function and when I call it at the class level, I see an error. My code:

    def subscriber_groups_ID(self, init_http_session, init_util):
        # get sub group
        response = init_http_session.get("/api/subscriberGroups", headers={"Authorization": init_util.auth_main_token()})
        subcriberGroupID = response.json()["subscriberGroups"][0]["subscriberGroupID"]

        return subcriberGroupID



subscriberGroupID = subscriber_groups_ID()
    json = [
            ({ "subscriberGroupID": subscriberGroupID, "subscriberTariffTypeID": "0"}),
            ({ "subscriberGroupID": subscriberGroupID, "subscriberTariffTypeID": Util.generate_tariff(Util)})
]

and error

TypeError: TestSubscribers.subscriber_groups_ID() missing 3 required positional arguments: 'self', 'init_http_session', and 'init_util'

Whats wrong and how to call it correct?

I try to use other ways and make this function in Utils class, but it not helps

1

There are 1 best solutions below

1
Mark On

subscriberGroupID = subscriber_groups_ID()

You called it with zero arguments.

Call it with self, and then whatever init_http_session and init_util you have.