9
9
from sphinx import locale
10
10
11
11
if TYPE_CHECKING :
12
- from collections .abc import Callable
12
+ from collections .abc import Callable , Iterator
13
13
from pathlib import Path
14
14
15
+ from sphinx .testing .util import SphinxTestApp
16
+
15
17
16
18
@pytest .fixture (autouse = True )
17
- def _cleanup_translations ():
19
+ def _cleanup_translations () -> Iterator [ None ] :
18
20
yield
19
21
locale .translators .clear ()
20
22
21
23
22
- def test_init (rootdir ) :
24
+ def test_init (rootdir : Path ) -> None :
23
25
# not initialized yet
24
26
_ = locale .get_translation ('myext' )
25
27
assert _ ('Hello world' ) == 'Hello world'
@@ -48,7 +50,7 @@ def test_init(rootdir):
48
50
assert _ ('Hello reST' ) == 'Hello reST'
49
51
50
52
51
- def test_init_with_unknown_language (rootdir ) :
53
+ def test_init_with_unknown_language (rootdir : Path ) -> None :
52
54
locale .init ([rootdir / 'test-locale' / 'locale1' ], 'unknown' , 'myext' )
53
55
_ = locale .get_translation ('myext' )
54
56
assert _ ('Hello world' ) == 'Hello world'
@@ -57,7 +59,7 @@ def test_init_with_unknown_language(rootdir):
57
59
58
60
59
61
@pytest .mark .sphinx ('html' , testroot = 'root' )
60
- def test_add_message_catalog (app , rootdir ) :
62
+ def test_add_message_catalog (app : SphinxTestApp , rootdir : Path ) -> None :
61
63
app .config .language = 'en'
62
64
app .add_message_catalog ('myext' , rootdir / 'test-locale' / 'locale1' )
63
65
_ = locale .get_translation ('myext' )
@@ -73,7 +75,9 @@ def _empty_language_translation(rootdir: Path) -> Callable[[str], str]:
73
75
return locale .get_translation (catalog )
74
76
75
77
76
- def test_init_environment_language (rootdir , monkeypatch ):
78
+ def test_init_environment_language (
79
+ rootdir : Path , monkeypatch : pytest .MonkeyPatch
80
+ ) -> None :
77
81
with monkeypatch .context () as m :
78
82
m .setenv ('LANGUAGE' , 'en_US:en' )
79
83
_ = _empty_language_translation (rootdir )
0 commit comments