Global State and Singleton cause the code hard to test youtube To use DI as possible.
add a .replit file with the following lines
language = "python3"
run = "python -m unittest discover -v"
def singleton(class_):
instances = {}
def getinstance(*args, **kwargs):
if class_ not in instances:
instances[class_] = class_(*args, **kwargs)
return instances[class_]
return getinstance
@singleton
class MyClass(BaseClass):
pass
*There are may other ways, refer to here in stackoverflow