How to run a constructor in Pytest?

Asked

Viewed 15 times

1

In my working directory, I have a folder that contains my package and another folder with test files. The directory tree is as follows:

Current_dir/

    MyPackage/
        __init__.py
        file1.py
        file2.py

    tests/
        __init__.py
        test_package.py

I am running, on the console, the command pytest tests. I want you to be executed first __init__, so I can add to the sys.path the directory that contains my package folder ("../"). That way I could import my package into the test archive.

However, the pytest does not perform the constructor, generating a ImportError in my test file. What I can do to run the constructor?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.