dj-twenty-six / 101

DJ26 Basic Introduction
GNU General Public License v3.0
3 stars 0 forks source link

pytest - No module named #12

Open assomdevgit opened 1 year ago

assomdevgit commented 1 year ago
 pytest
============================================================================================== test session starts ==============================================================================================
platform linux -- Python 3.8.18, pytest-7.4.2, pluggy-1.3.0
rootdir: /home/user/code/hello-assome
collected 0 items / 1 error

==================================================================================================== ERRORS =====================================================================================================
______________________________________________________________________________________ ERROR collecting tests/test_who.py _______________________________________________________________________________________
ImportError while importing test module '/home/user/code/hello-assome/tests/test_who.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../.pyenv/versions/3.8.18/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_who.py:1: in <module>
    from hello_assome.who import my_name
E   ModuleNotFoundError: No module named 'hello_assome'
============================================================================================ short test summary info ============================================================================================
ERROR tests/test_who.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=============================================================================================== 1 error in 0.06s ================================================================================================
(hello-assome-3.8)  ✘ user@LAPTOP-VK3HIFSD  ~/code/hello-assome  tree
.
├── README.md
├── __pycache__
├── pdm.lock
├── pyproject.toml
├── src
│   └── hello_assome
│       ├── __init__.py
│       ├── __pycache__
│       └── who.py
└── tests
    ├── __init__.py
    ├── __pycache__
    │   ├── __init__.cpython-38.pyc
    │   └── test_who.cpython-38-pytest-7.4.2.pyc
    └── test_who.py

6 directories, 9 files
(hello-assome-3.8)  user@LAPTOP-VK3HIFSD  ~/code/hello-assome 
pySatellite commented 1 year ago

이런 솔루션이 있는데 한번 봐주세요.

pySatellite commented 1 year ago

which pytest 해서 해당 프로젝트의 가상환경이 아닌 pytest 가 잡히면 제거해주고 해결 하였습니다.