-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathtest_arguments.py
More file actions
61 lines (50 loc) · 1.92 KB
/
test_arguments.py
File metadata and controls
61 lines (50 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import pytest
from fluent.runtime import FluentBundle, FluentResource
from ..utils import dedent_ftl
class TestNumbersInValues:
@pytest.fixture
def bundle(self):
bundle = FluentBundle(["en-US"], use_isolating=False)
bundle.add_resource(
FluentResource(
dedent_ftl(
"""
foo = Foo { $num }
bar = { foo }
baz =
.attr = Baz Attribute { $num }
qux = { "a" ->
*[a] Baz Variant A { $num }
}
"""
)
)
)
return bundle
def test_can_be_used_in_the_message_value(self, bundle):
val, errs = bundle.format_pattern(bundle.get_message("foo").value, {"num": 3})
assert val == "Foo 3"
assert len(errs) == 0
def test_can_be_used_in_the_message_value_which_is_referenced(self, bundle):
val, errs = bundle.format_pattern(bundle.get_message("bar").value, {"num": 3})
assert val == "Foo 3"
assert len(errs) == 0
def test_can_be_used_in_an_attribute(self, bundle):
val, errs = bundle.format_pattern(
bundle.get_message("baz").attributes["attr"], {"num": 3}
)
assert val == "Baz Attribute 3"
assert len(errs) == 0
def test_can_be_used_in_a_variant(self, bundle):
val, errs = bundle.format_pattern(bundle.get_message("qux").value, {"num": 3})
assert val == "Baz Variant A 3"
assert len(errs) == 0
class TestStrings:
def test_can_be_a_string(self):
bundle = FluentBundle(["en-US"], use_isolating=False)
bundle.add_resource(FluentResource("foo = { $arg }"))
val, errs = bundle.format_pattern(
bundle.get_message("foo").value, {"arg": "Argument"}
)
assert val == "Argument"
assert len(errs) == 0