Skip to content Skip to sidebar Skip to footer

Pytest Run Tests Inside A Class With A Constructor

I want to write a test suite for an API. my project tree looks like: project tree I need to have a 'client' file with classes where we initialize all the helper functions(e.g. the

Solution 1:

Yes, you are correct, if "__init__()" is defined in the class, then the py-test would not collect the classes for the testing purpose. But, if you want to initialize all the helper methods and file, then you could add that file in the pythonpaths in pytest.ini configuration file like below:-

[pytest]python_paths = . <path to helper file>

And from then, you could directly import that particular file in your test script.

I hope you find your answer.

Post a Comment for "Pytest Run Tests Inside A Class With A Constructor"