silviud
silviud

Reputation: 1025

Python pyramid i18n and pytest

I followed pyramid i18n to add translations into my application under the locale which works fine but pytest is not happy at all - I get errors like this

    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 

The app/__init__.py adds translations with config.add_translation_dirs('app:locale/')

pytest.ini

[pytest]
testpaths = tests
python_files = *.py
addopts = -p no:warning

The structure is

app/
tests/
setup.py
pytest.ini
...

Thank you,

PS: I found the same issue if I add the deform translations

Upvotes: 0

Views: 185

Answers (1)

Michael Merickel
Michael Merickel

Reputation: 23331

I suspect you aren't invoking config.begin() and config.end() correctly around your tests such that the threadlocals are active. It completely depends on how your tests look what this actually means though. Pyramid's i18n system relies on the threadlocals being pushed properly for the duration of the test.

Upvotes: 1

Related Questions