Project

General

Profile

« Previous | Next » 

Revision bd588eb9

Added by koszko over 1 year ago

add missing english translations and verify message texts of raised exceptions in tests

View differences:

conftest.py
8 8
from pathlib import Path
9 9

  
10 10
import pytest
11
import pkgutil
11 12

  
12 13
here = Path(__file__).resolve().parent
13 14
sys.path.insert(0, str(here / 'src'))
......
34 35
        run = mocked_run
35 36

  
36 37
    monkeypatch.setattr(where, 'subprocess', MockedSubprocess)
38

  
39
@pytest.fixture(autouse=True)
40
def no_gettext(monkeypatch, request):
41
    """
42
    Make gettext return all strings untranslated unless we request otherwise.
43
    """
44
    if request.node.get_closest_marker('enable_gettext'):
45
        return
46

  
47
    import hydrilla
48
    modules_to_process = [hydrilla]
49

  
50
    def add_child_modules(parent):
51
        """
52
        Recursuvely collect all modules descending from 'parent' into an array.
53
        """
54
        try:
55
            load_paths = parent.__path__
56
        except AttributeError:
57
            return
58

  
59
        for module_info in pkgutil.iter_modules(load_paths):
60
            if module_info.name != '__main__':
61
                __import__(f'{parent.__name__}.{module_info.name}')
62
                modules_to_process.append(getattr(parent, module_info.name))
63
                add_child_modules(getattr(parent, module_info.name))
64

  
65
    add_child_modules(hydrilla)
66

  
67
    for module in modules_to_process:
68
        if hasattr(module, '_'):
69
            monkeypatch.setattr(module, '_', lambda message: message)

Also available in: Unified diff