Skip to content

Commit

Permalink
Add unit tests for fmt_converter_call
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Mar 21, 2024
1 parent f1ce8d7 commit 0a2ccc8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,34 @@ def test_pickle(self, takes_self, takes_field):

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

@pytest.mark.parametrize(
"scenario",
[
((False, False), "__attr_converter_le_name(le_value)"),
(
(True, True),
"__attr_converter_le_name(le_value, self, attr_dict['le_name'])",
),
(
(True, False),
"__attr_converter_le_name(le_value, self)",
),
(
(False, True),
"__attr_converter_le_name(le_value, attr_dict['le_name'])",
),
],
)
def test_fmt_converter_call(self, scenario):
"""
_fmt_converter_call determines the arguments to the wrapped converter
according to `takes_self` and `takes_field`.
"""
(takes_self, takes_field), expect = scenario
c = Converter(None, takes_self=takes_self, takes_field=takes_field)

assert expect == c._fmt_converter_call("le_name", "le_value")


class TestOptional:
"""
Expand Down

0 comments on commit 0a2ccc8

Please sign in to comment.