dimanche 22 septembre 2019

ImportError during Unittest discover on tests root directory

Running tests discover using these format works:

python -m unittest discover tests/folder1/folder2 -v
python -m unittest discover tests/folder1

The issue happens when I'm running the discover tests on the root directory of the tests scripts.

python -m unittest discover tests  # raised ImportError

My project structure looks like this:

project_name/
    src/
        __init__.py
        # modules
    tests/
        folder1/
            __init__.py
            folder2/
                # test scripts
                __init__.py
        __init__.py

Based on what I read on some related post, the issue was with the PATH. but I already include the src path by running this command and the ImportError still occurs.

export PYTHONPATH=$PYTHONPATH:$(pwd)/src

Aucun commentaire:

Enregistrer un commentaire