Skip to content

Commit eeebc5a

Browse files
committed
Add unit tests for fmt_converter_call
1 parent 06c0716 commit eeebc5a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test_converters.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,34 @@ def test_pickle(self, takes_self, takes_field):
2525

2626
assert c == pickle.loads(pickle.dumps(c))
2727

28+
@pytest.mark.parametrize(
29+
"scenario",
30+
[
31+
((False, False), "__attr_converter_le_name(le_value)"),
32+
(
33+
(True, True),
34+
"__attr_converter_le_name(le_value, self, attr_dict['le_name'])",
35+
),
36+
(
37+
(True, False),
38+
"__attr_converter_le_name(le_value, self)",
39+
),
40+
(
41+
(False, True),
42+
"__attr_converter_le_name(le_value, attr_dict['le_name'])",
43+
),
44+
],
45+
)
46+
def test_fmt_converter_call(self, scenario):
47+
"""
48+
_fmt_converter_call determines the arguments to the wrapped converter
49+
according to `takes_self` and `takes_field`.
50+
"""
51+
(takes_self, takes_field), expect = scenario
52+
c = Converter(None, takes_self=takes_self, takes_field=takes_field)
53+
54+
assert expect == c._fmt_converter_call("le_name", "le_value")
55+
2856

2957
class TestOptional:
3058
"""

0 commit comments

Comments
 (0)