mardi 1 septembre 2020

unit test input validation (python)

I do the following input validation check:

self.path = kwargs.get('path', default_path) 
if not os.path.isdir(self.path): 
    raise ValueError(msg1)
if not os.access(self.path, os.W_OK):
        raise ValueError(msg2)

What would be the best way to test it (in unit test)?

clarification: I want to check the following:

  • function should raise a ValueError if path is not a directory
  • function should raise a ValueError if path is a directory that is not writable

Aucun commentaire:

Enregistrer un commentaire