Python 金字塔 i18n 和 pytest
Python pyramid i18n and pytest
我按照 pyramid i18n 在 locale
下将翻译添加到我的应用程序中,它工作正常,但 pytest
一点也不开心 - 我收到这样的错误
def _isdir(self, path):
> raise NotImplementedError(
"Can't perform this operation for unregistered loader type"
)
E pyramid.exceptions.ConfigurationExecutionError: <class 'NotImplementedError'>: Can't perform this operation for unregistered loader
app/__init__.py
增加翻译config.add_translation_dirs('app:locale/')
pytest.ini
[pytest]
testpaths = tests
python_files = *.py
addopts = -p no:warning
结构为
app/
tests/
setup.py
pytest.ini
...
谢谢,
PS:如果我添加变形翻译,我发现了同样的问题
我怀疑您没有在测试周围正确地调用 config.begin()
和 config.end()
以致线程局部变量处于活动状态。这完全取决于您的测试看起来如何,但这实际上意味着什么。 Pyramid 的 i18n 系统依赖于在测试期间正确推送的 threadlocals。
我按照 pyramid i18n 在 locale
下将翻译添加到我的应用程序中,它工作正常,但 pytest
一点也不开心 - 我收到这样的错误
def _isdir(self, path):
> raise NotImplementedError(
"Can't perform this operation for unregistered loader type"
)
E pyramid.exceptions.ConfigurationExecutionError: <class 'NotImplementedError'>: Can't perform this operation for unregistered loader
app/__init__.py
增加翻译config.add_translation_dirs('app:locale/')
pytest.ini
[pytest]
testpaths = tests
python_files = *.py
addopts = -p no:warning
结构为
app/
tests/
setup.py
pytest.ini
...
谢谢,
PS:如果我添加变形翻译,我发现了同样的问题
我怀疑您没有在测试周围正确地调用 config.begin()
和 config.end()
以致线程局部变量处于活动状态。这完全取决于您的测试看起来如何,但这实际上意味着什么。 Pyramid 的 i18n 系统依赖于在测试期间正确推送的 threadlocals。