bumpy-noon-80834
09/29/2022, 10:38 PM$ ./pants test ::
00:31:26.68 [ERROR] Completed: Run Pytest - packages/libhello/tests/test_hello.py failed (exit code 2).
============================= test session starts ==============================
platform linux -- Python 3.9.14, pytest-7.0.1, pluggy-1.0.0
rootdir: /tmp/pants-sandbox-8eRczK
plugins: cov-3.0.0
collected 0 items / 1 error
==================================== ERRORS ====================================
____________ ERROR collecting packages/libhello/tests/test_hello.py ____________
ImportError while importing test module '/tmp/pants-sandbox-8eRczK/packages/libhello/tests/test_hello.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
packages/libhello/tests/test_hello.py:1: in <module>
from libhello import hello
E ModuleNotFoundError: No module named 'libhello'
- generated xml file: /tmp/pants-sandbox-8eRczK/packages.libhello.tests.test_hello.py.xml -
=========================== short test summary info ============================
ERROR packages/libhello/tests/test_hello.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.06s ===============================
What am I getting wrong?enough-analyst-54434
09/29/2022, 10:50 PMbumpy-noon-80834
09/29/2022, 10:51 PM$ ./pants roots
packages/libhello/src
packages/libhello/tests
careful-address-89803
09/29/2022, 10:53 PMlibhello
isn't a resolvable module, so the test's import isn't resolvedenough-analyst-54434
09/29/2022, 10:53 PMhundreds-father-404
09/29/2022, 10:53 PMbumpy-noon-80834
09/29/2022, 10:55 PM$ tree packages/
packages/
└── libhello
├── src
│ ├── BUILD
│ ├── hello.py
│ └── __init__.py
└── tests
├── BUILD
└── test_hello.py
$ cat packages/libhello/src/__init__.py
from .hello import hello
$ cat packages/libhello/src/hello.py
def hello(name):
return f'Hello {name}'
$ cat packages/libhello/tests/test_hello.py
from libhello import hello
def test_hello():
assert hello('world') == 'Hello world'
enough-analyst-54434
09/29/2022, 10:55 PMfrom libhello import hello
. There is no `libhello`package, just hello.py
src
directory or else just repeat yourself less in the naming.bumpy-noon-80834
09/29/2022, 10:58 PMenough-analyst-54434
09/29/2022, 10:58 PMsrc
directories.bumpy-noon-80834
09/29/2022, 11:01 PMhundreds-father-404
09/29/2022, 11:08 PMhappy-kitchen-89482
09/29/2022, 11:09 PMbumpy-noon-80834
09/29/2022, 11:14 PMwitty-crayon-22786
09/30/2022, 12:06 AM