pyapp-org/pyapp

Injection framework raising exceptions when resolving from an extesion during test cases

Opened this issue · 2 comments

Extensions are loaded at application startup causing factories to be registered. In test cases however, this step does not get executed leading to exceptions.

A workaround is to load extensions in conftest.py (pytest) and call their ready method to cause factories to be registered.

This issue also manifests using an inject on a cli command. A better solution may be to delay when injection is resolved to first call and cache the result.

A solution to this issue would also be useful for applications that do not use CliApplication, a helper method that initialises extensions and uses that to load all settings, including those in extensions. This would bypass this problem