Тип проблемы: Запрос разъяснений
Среда
Linux Mint 21.3 (ядро 5.15.0-117-generic), Python 3.10.12 с использованием pytestarch == 3.0.1
Справочная информация
- Путь моего проекта — /home/developer/python/snakes-and-ladders-engine, и он имеет структуру папок:
Код: Выделить всё
├── src
│ ├── game
│ │ └── game.py
│ └── utils
│ └── gameutilities.py
└── tests
└── architecture
└── test_architecture.py
- Модуль gameutilities.py содержит только методы — в файле не определены классы.
- импортирует gameutilities.py как
Код: Выделить всё
game.py
Код: Выделить всё
from ..utils import gameutilities as GameUtilities
Код: Выделить всё
@pytest.fixture
def game_architecture_instance(project_root: Path, src_root: Path) -> EvaluableArchitecture:
return get_evaluable_architecture(str(project_root), str(src_root))
Я пытаюсь определить правило "
Код: Выделить всё
gameutilitiesКод: Выделить всё
def test_utilities_invocation_rule(game_architecture_instance: EvaluableArchitecture) -> None:
utils_name: str = "snakes-and-ladders-engine.src.utils.gameutilities"
game_name: str = "snakes-and-ladders-engine.src.game.game"
utilities_invocation_rule: Rule = (
Rule().modules_that()
.are_named(utils_name)
.should_only().be_imported_by_modules_that()
.are_named(game_name)
)
utilities_invocation_rule.assert_applies(game_architecture_instance)
Код: Выделить всё
AssertionError: "snakes-and-ladders-engine.src.utils.gameutilities" is not imported by "snakes-and-ladders-engine.src.game.game".
Правило настроено неправильно ? Что я здесь делаю не так? Мы будем очень признательны за любую поддержку по исправлению этой ошибки.
Подробнее здесь: https://stackoverflow.com/questions/788 ... uleb-using