vendredi 22 février 2019

How to pass command line parameters in a python test

I have a microservice class MsActionDetector. It takes an argument from the command line because the ms is launched within a .sh script, both locally and inside a container.

class MsActionDetector(BaseMicroservice):

    def __init__(self):
        self.config = safe_load(open(sys.argv[1]))
        ....

I would like to perform integration tests thus instantiating my microservice in a test, but that doesn't work because the class excepts a command line argument. How can I achieve this? Is python Decorator a solution? Should I modify my constructor?

Aucun commentaire:

Enregistrer un commentaire