Skip to content

Commit

Permalink
Changed parameter names as requested
Browse files Browse the repository at this point in the history
  • Loading branch information
rnemes committed Nov 15, 2023
1 parent 89a7e04 commit 871519c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion doc/newsfragments/2691_changed.fix_match_assertion.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Introduced a new parameter ``include_only_tags_of_expected`` for py:meth:`result.fix.match() <testplan.testing.multitest.result.FixNamespace.match>` assertion, It will only compares the tags present in the expected message when the parameter is set to `True`.
Introduced a new parameter ``include_only_expected`` for py:meth:`result.fix.match() <testplan.testing.multitest.result.FixNamespace.match>` assertion, It will only compares the tags present in the expected message when the parameter is set to `True`.
20 changes: 10 additions & 10 deletions testplan/common/utils/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def _cmp_dicts(
include: Container,
report_mode: int,
value_cmp_func: Union[Callable, None],
include_only_keys_of_rhs: bool = False,
include_only_rhs: bool = False,
) -> Tuple[str, List]:
"""
Compares two dictionaries with optional restriction to keys,
Expand All @@ -505,7 +505,7 @@ def should_ignore_key(key: Hashable) -> bool:
"""
if key in ignore:
should_ignore = True
elif include_only_keys_of_rhs is True:
elif include_only_rhs is True:
should_ignore = key not in rhs.keys()
elif include is not None:
should_ignore = key not in include
Expand All @@ -529,7 +529,7 @@ def should_ignore_key(key: Hashable) -> bool:
key=iter_key,
report_mode=report_mode,
value_cmp_func=None,
include_only_keys_of_rhs=include_only_keys_of_rhs,
include_only_rhs=include_only_rhs,
)
)
else:
Expand All @@ -541,7 +541,7 @@ def should_ignore_key(key: Hashable) -> bool:
key=iter_key,
report_mode=report_mode,
value_cmp_func=value_cmp_func,
include_only_keys_of_rhs=include_only_keys_of_rhs,
include_only_rhs=include_only_rhs,
)
# Decide whether to keep or discard the result, depending on the
# reporting mode.
Expand All @@ -567,7 +567,7 @@ def _rec_compare(
report_mode,
value_cmp_func,
_regex_adapter=RegexAdapter,
include_only_keys_of_rhs=False,
include_only_rhs=False,
):
"""
Recursive deep comparison implementation
Expand Down Expand Up @@ -685,7 +685,7 @@ def _rec_compare(
key=None,
report_mode=report_mode,
value_cmp_func=value_cmp_func,
include_only_keys_of_rhs=include_only_keys_of_rhs,
include_only_rhs=include_only_rhs,
)

match = Match.combine(match, result[1])
Expand All @@ -707,7 +707,7 @@ def _rec_compare(
include=include,
report_mode=report_mode,
value_cmp_func=value_cmp_func,
include_only_keys_of_rhs=include_only_keys_of_rhs,
include_only_rhs=include_only_rhs,
)
lhs_vals, rhs_vals = _partition(results)
return _build_res(
Expand Down Expand Up @@ -789,7 +789,7 @@ def compare(
value_cmp_func: typing_Callable[[Any, Any], bool] = COMPARE_FUNCTIONS[
"native_equality"
],
include_only_keys_of_rhs: bool = False,
include_only_rhs: bool = False,
) -> Tuple[bool, List[Tuple]]:
"""
Compare two iterable key, value objects (e.g. dict or dict-like mapping)
Expand All @@ -807,7 +807,7 @@ def compare(
for more detail.
:param value_cmp_func: function to compare values in a dict. Defaults
to COMPARE_FUNCTIONS['native_equality'].
:param include_only_keys_of_rhs: use the keys present in rhs.
:param include_only_rhs: use the keys present in rhs.
:return: Tuple of comparison bool ``(passed: True, failed: False)`` and
a description object for the testdb report
Expand Down Expand Up @@ -847,7 +847,7 @@ def compare(
include=include,
report_mode=report_mode,
value_cmp_func=value_cmp_func,
include_only_keys_of_rhs=include_only_keys_of_rhs,
include_only_rhs=include_only_rhs,
)

# For the keys in include not matching anything,
Expand Down
10 changes: 5 additions & 5 deletions testplan/testing/multitest/entries/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ def __init__(
self,
value: Dict,
expected: Dict,
include_only_keys_of_expected: bool = False,
include_only_expected: bool = False,
include_keys: List[Hashable] = None,
exclude_keys: List[Hashable] = None,
report_mode=comparison.ReportOptions.ALL,
Expand All @@ -1320,7 +1320,7 @@ def __init__(
):
self.value = value
self.expected = expected
self.include_only_keys_of_expected = include_only_keys_of_expected
self.include_only_expected = include_only_expected
self.include_keys = include_keys
self.exclude_keys = exclude_keys
self.actual_description = actual_description
Expand All @@ -1342,7 +1342,7 @@ def evaluate(self):
include=self.include_keys,
report_mode=self._report_mode,
value_cmp_func=self._value_cmp_func,
include_only_keys_of_rhs=self.include_only_keys_of_expected,
include_only_rhs=self.include_only_expected,
)
self.comparison = flatten_dict_comparison(cmp_result)
return passed
Expand All @@ -1358,7 +1358,7 @@ def __init__(
self,
value: Dict,
expected: Dict,
include_only_tags_of_expected: bool = False,
include_only_expected: bool = False,
include_tags: List[Hashable] = None,
exclude_tags: List[Hashable] = None,
report_mode=comparison.ReportOptions.ALL,
Expand All @@ -1383,7 +1383,7 @@ def __init__(
super(FixMatch, self).__init__(
value=value,
expected=expected,
include_only_keys_of_expected=include_only_tags_of_expected,
include_only_expected=include_only_expected,
include_keys=include_tags,
exclude_keys=exclude_tags,
report_mode=report_mode,
Expand Down
12 changes: 6 additions & 6 deletions testplan/testing/multitest/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ def match(
self,
actual: Dict,
expected: Dict,
include_only_keys_of_expected: bool = False,
include_only_expected: bool = False,
description: str = None,
category: str = None,
include_keys: List[Hashable] = None,
Expand Down Expand Up @@ -990,7 +990,7 @@ def match(
:param actual: Original dictionary.
:param expected: Comparison dictionary, can contain custom comparators
(e.g. regex, lambda functions)
:param include_only_keys_of_expected: Use the keys present in the expected message.
:param include_only_expected: Use the keys present in the expected message.
:param include_keys: Keys to exclusively consider in the comparison.
:param exclude_keys: Keys to ignore in the comparison.
:param report_mode: Specify which comparisons should be kept and
Expand All @@ -1012,7 +1012,7 @@ def match(
value=actual,
expected=expected,
description=description,
include_only_keys_of_expected=include_only_keys_of_expected,
include_only_expected=include_only_expected,
include_keys=include_keys,
exclude_keys=exclude_keys,
report_mode=report_mode,
Expand Down Expand Up @@ -1174,7 +1174,7 @@ def match(
self,
actual: Dict,
expected: Dict,
include_only_tags_of_expected: bool = False,
include_only_expected: bool = False,
description: str = None,
category: str = None,
include_tags: List[Hashable] = None,
Expand Down Expand Up @@ -1210,7 +1210,7 @@ def match(
:param expected: Expected FIX message, can include compiled
regex patterns or callables for
advanced comparison.
:param include_only_tags_of_expected: Use the tags present in the expected message.
:param include_only_expected: Use the tags present in the expected message.
:param include_tags: Tags to exclusively consider in the comparison.
:param exclude_tags: Keys to ignore in the comparison.
:param report_mode: Specify which comparisons should be kept and
Expand All @@ -1230,7 +1230,7 @@ def match(
expected=expected,
description=description,
category=category,
include_only_tags_of_expected=include_only_tags_of_expected,
include_only_expected=include_only_expected,
include_tags=include_tags,
exclude_tags=exclude_tags,
report_mode=report_mode,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/testplan/testing/multitest/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ def test_subset_of_tags_with_include_tags_true(self, fix_ns):
actual=actual,
expected=expected,
description="complex fix message comparison",
include_only_tags_of_expected=True,
include_only_expected=True,
)
assert len(fix_ns.result.entries) == 1

Expand Down

0 comments on commit 871519c

Please sign in to comment.