0

This should be simple, but I am struggling. I want one folder for my code and another folder for my tests, to test the code in the working_code folder.

code/
│
├── working_code/
│   ├── __init__.py
│   └── some_code.py
│
├── tests/
│   ├── __init__.py
│   └── test_some_code.py
│
└── __init__.py

However when I try to import the "some_code" module in the "test_some_code" module:

import working_code.some_code

It gives an error: ModuleNotFoundError: No module named 'working_code' But to my knowledge working_code is a package. What am I missing here?

arne
  • 21
  • 4
  • Try "from working_code.some_code import func_name" – Mark Sep 23 '20 at 19:40
  • Check what `sys.path` contains. Essentially, to perform a ‘parallel’ import, the `code` directory must be in `sys.path`. – S3DEV Sep 23 '20 at 19:44
  • Does this answer your question? [Python import src modules when running tests](https://stackoverflow.com/questions/4761041/python-import-src-modules-when-running-tests) – mkrieger1 Sep 23 '20 at 19:49
  • Yes adding the path did the trick, thanks. – arne Sep 27 '20 at 12:05

0 Answers0