mercredi 1 juin 2022

dependency the tested class or function to another parts of program

I am trying to write some tests for my program but I have an essential question. look at the below code :

class Redis:
    host: str
    def __init__(self) -> None:
        self.load_config()
        print(self.host, self.key_prefix)

    def load_config(self):
        self.host, self.key_prefix = load_redis_config()

as you see I have used an external function with the name load_redis_config, but if when run test cases of class Redis fall because of load_redis_config or another dependency what do I do? I wrote some test cases for load_redis_config or another external dependency. are has some principles or rules for this situation? tell me if there are such things, advance thanks

Aucun commentaire:

Enregistrer un commentaire