Linked Questions
11 questions linked to/from pytest cannot import module while python can
0
votes
0
answers
47
views
How do I specify the correct import in tests? [duplicate]
I use pytest. I have a "kernel" folder in the root of the project in which the file is located "ecommerce.py"
Full path "./kernel/ecommerce.py" I have a unit test that ...
448
votes
29
answers
458k
views
PATH issue with pytest 'ImportError: No module named ...'
I used easy_install to install pytest on a Mac and started writing tests for a project with a file structure likes so:
repo/
|--app.py
|--settings.py
|--models.py
|--tests/
|--...
113
votes
18
answers
128k
views
ModuleNotFoundError with pytest
I want my tests folder separate to my application code. My project structure is like so
myproject/
myproject/
myproject.py
moduleone.py
tests/
myproject_test.py
myproject.py
from ...
9
votes
3
answers
36k
views
How to solve ImportError with pytest
There were already questions regarding this topic. Sometimes programmers put some __init__.py at some places, often it is said one should use absolute paths. However, I don't get it to work here:
How ...
1
vote
2
answers
2k
views
Azure Devops pipeline pytest collection failure ModuleNotFoundError: No module named
I get the following error when running an azure pipeline.
Here is the pytest part of my pipelines yaml file.
steps:
#test
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python....
0
votes
2
answers
1k
views
pytest and pybind11: can't import c++ extension
I use pybind11 to add a module _cxx to existing python library liba.
The liba._cxx.func doesn't exist until I compile the c++ extension and install the whole library by setup.py.
When I run tests in ...
1
vote
1
answer
735
views
ImportError: cannot import name 'CustomerIdNameSerializer' from 'contacts.api.serializers'
I have been trying to craft some unit tests for pytest. The server runs just fine when I do 'python manage.py runserver'. However, when I do 'pytest', it shows the following error:
====================...
1
vote
1
answer
1k
views
Python pytest - ModuleNotFoundError: No module named 'prompts'
Running pytest in the terminal results in the below error. The application runs fine with python3 main.py from the src/ directory, however pytest throws this error.
...
1
vote
0
answers
494
views
sys.path incorrect in Pytest
I have been having a lot of trouble trying to run pytest. Basically the importing was not working properly. Let me explain. The folder structure of my project is the following:
src
└── api
├── ...
0
votes
1
answer
725
views
Python module import issue when using pytest
I have a Python project set up with venv as the virtual environment (directory structure is attached below). When I try to run the tests with pytest (or python -m pytest tests or python -m pytest), I ...
1
vote
0
answers
213
views
Can't run tests with brownie
I have one test, in the directory tests, when I run brownie test
cannot import name 'PYTEST_COLLECT_MODULE' from '_pytest.deprecated'
python version : 3.7.11