PYTEST: Module not found error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
Hi,
Apologies, as I am trying to use Pytest first time. I know this question has been raised but I went through previous answers but the issue still exists.
I am following DAtabricks and other articles using pytest. My structure is simple as
-tests
--common [Folder]
---- __init__.py
---- utils.py
--test_tran.py
--test_utils.py
--exectest.ipynb
Common[Folder],test_tran,test_utils and exectest files are at same level. test_utils refers utils.py
My test files work fine [test_tran and test_utils].
When I try to execute exectest notebook, I am thrown error
_______________________ ERROR collecting test_tran.py _________________________ ImportError while importing test module '/Workspace/Users/...../test/tests/test_tran.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: /usr/lib/python3.11/importlib/__init__.py:126: in import_module return _bootstrap._gcd_import(name[level:], package, level) E ModuleNotFoundError: No module named 'test_tran'
This error is thrown for both test_tran and test_utils files.
I have tried with VS Code [bundle], and it is the same result.
Code of exectest.ipynb file:

