Похожие чаты

I am a Python beginner and I am very much

hoping someone can help me out setting up pytest.

This is my attempt at writing a test for my super-basic class:
test_message.py:
from crmpicco.subtasks.legacy import Legacy

def test_is_complete(self):
legacy = Legacy()
assert legacy.is_complete(self) == True

legacy.py looks like this:

from crmpicco.subtasks.subtask import Subtask


class Legacy(Subtask):
def execute(self):
print("legacy")

def is_complete(self):
return True

When I run the test from the directory the class lives in it can't seem to reference or find the "crmpicco" module for some reason...

pytest test_message.py

ERROR collecting test_message.py _______________________________________________________________
ImportError while importing test module '/private/var/www/crmpicco/crmpicco/subtasks/test_message.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
test_message.py:1: in <module>
from crmpicco.subtasks.legacy import Legacy
E ModuleNotFoundError: No module named 'crmpicco'

What am I doing wrong? Any help is appreciated, thanks :-)

2 ответов

28 просмотров

You have installed PyTest and made sure it worked with the code snippet available in the docs before trying to make it work with your own tailored code, haven't you?

Craig R-Morton Автор вопроса
Pedro Aguiar
You have installed PyTest and made sure it worked ...

Thanks for the reply. Yes, I can run a simple test without any issues. I can also run the test if I move it into that directory, so clear there's an issue with the "crmpicco" module or how I am referencing it when I have the test in a separate /tests directory. Can you spot the issue from my code above?

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта