How can I structure my folders to test my code:
问题 I'm working on a project and would like to write some unit tests for my code. Here is a minimal example of my project structure myproject └── scripts ├── tests │ └── test_func.py └── tools ├── __init__.py └── func.py func.py contains def f(x): return 0 and test_func.py contains import pytest from ..tools import f def test_f(): assert f(1)==0 When I try to run my tests with pytest pytest scripts/tests/test_func.py , I get the following error ImportError: attempted relative import with no known