From a15716485db91eaf937881574e9dfc1e2e484e1e Mon Sep 17 00:00:00 2001 From: Bernhard Hagmann Date: Fri, 25 Oct 2024 15:03:08 +0200 Subject: [PATCH] SIANXKE-414: Add pre-commit configuration and checks in pipeline --- .github/workflows/test.yml | 7 +- .pre-commit-config.yaml | 27 ++++ LICENSE | 1 - README.md | 14 +- deepcompare/__init__.py | 32 +++-- requirements.txt | 6 +- setup.py | 42 +++--- tests/test_compare_deep.py | 186 ++++++++++++++++++-------- tests/test_compare_flat.py | 159 +++++++++++----------- tests/test_partial_compare_deep.py | 204 +++++++++++++++++++++-------- tests/test_partial_compare_flat.py | 170 +++++++++++++----------- 11 files changed, 546 insertions(+), 302 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f5c9c0a..f277ad3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,12 +27,9 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt - - name: Lint with flake8 + - name: Run linters and format checks run: | - # stop the build if there are Python syntax errors or undefined names - flake8 './deepcompare' --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 './deepcompare' --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + pre-commit run --all-files - name: Run tests run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..4ce655d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-merge-conflict + - id: end-of-file-fixer + - id: requirements-txt-fixer + - id: trailing-whitespace + args: ["--markdown-linebreak-ext=md"] + + - repo: https://github.com/asottile/pyupgrade + rev: v3.17.0 + hooks: + - id: pyupgrade + args: ["--py39-plus"] + + - repo: https://github.com/asottile/add-trailing-comma + rev: v3.1.0 + hooks: + - id: add-trailing-comma + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.9 + hooks: + - id: ruff + args: [ --fix ] + - id: ruff-format diff --git a/LICENSE b/LICENSE index 7ed0a54..1e7f292 100644 --- a/LICENSE +++ b/LICENSE @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md index 425de80..880d96c 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ deepcompare [![Test Status](https://github.com/anexia/python-deepcompare/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/anexia/python-deepcompare/actions/workflows/test.yml) [![Codecov](https://codecov.io/gh/anexia/python-deepcompare/branch/main/graph/badge.svg)](https://codecov.io/gh/anexia/python-deepcompare) -`deepcompare` is a library to deep compare data structures with each other. It can check if two data -structures contain the same data, or if a data structure is a subset of another data structure. The library +`deepcompare` is a library to deep compare data structures with each other. It can check if two data +structures contain the same data, or if a data structure is a subset of another data structure. The library supports `Sequence` (e.g. `list` or `tuple`) and `Mapping` (e.g. `dict`) types for the deep comparison. # Installation @@ -26,15 +26,15 @@ pip install deepcompare # Getting started ## How it works - - As a default, the comparison treats all `Sequence` and all `Mapping` types the same (e.g. `(1, 2, 3)` is equal to + - As a default, the comparison treats all `Sequence` and all `Mapping` types the same (e.g. `(1, 2, 3)` is equal to `[1, 2, 3]`). To enable strict type checks, use the `strict` keyword argument. - The `partial_compare` method checks if the data structure given as the second parameter is a subset of the data structure given as the first parameter. - For `Mapping` types this means, that all keys of the second data structure are also keys on the first data - structure, and the values of the keys are also equal (e.g. `{'a': 1, 'b': 2}` is a subset + structure, and the values of the keys are also equal (e.g. `{'a': 1, 'b': 2}` is a subset of `{'a': 1, 'b': 2, 'c': 3}`, but `{'a': 1, 'b': 2, 'd': 4}` is not). - For `Sequence` types this means, that all values of the second data structure are also values of the first data - structure, and the values are in the same order (e.g. `[1, 3, 5]` is a subset + structure, and the values are in the same order (e.g. `[1, 3, 5]` is a subset of `[1, 2, 3, 4, 5]`, but `[1, 5, 3]` is not). ## Usage @@ -55,14 +55,14 @@ deepcompare.compare( strict=True, ) # returns: False -# test if the second data structure is contained within the first, but +# test if the second data structure is contained within the first, but # the types to not need to match exactly deepcompare.partial_compare( {'key1': (1, 2, 3), 'key2': {'key3': [4, 5, 6]}, 'key4': True}, {'key1': [1, 2], 'key2': {'key3': (4, 6)}}, ) # returns: True -# test if the second data structure is contained within the first, and +# test if the second data structure is contained within the first, and # make sure the types match exactly deepcompare.partial_compare( {'key1': (1, 2, 3), 'key2': {'key3': [4, 5, 6]}, 'key4': True}, diff --git a/deepcompare/__init__.py b/deepcompare/__init__.py index ce5e7c7..9d054db 100644 --- a/deepcompare/__init__.py +++ b/deepcompare/__init__.py @@ -2,13 +2,13 @@ from typing import Any __all__ = [ - 'compare', - 'partial_compare', + "compare", + "partial_compare", ] -_LIST_TYPES = (abc.Sequence, ) -_DICT_TYPES = (abc.Mapping, ) -_STR_TYPES = (str, bytes, ) +_LIST_TYPES = (abc.Sequence,) +_DICT_TYPES = (abc.Mapping,) +_STR_TYPES = (str, bytes) def compare(haystack: Any, subset: Any, strict: bool = False) -> bool: @@ -64,8 +64,12 @@ def _compare(haystack: Any, subset: Any, partial: bool, strict: bool) -> bool: # if we compare two list types, we check each value of the haystack object to be equal to the # subset object. if we are working in partial mode, we ignore if the subset list is shorter than the haystack list. - elif isinstance(haystack, _LIST_TYPES) and not isinstance(haystack, _STR_TYPES) \ - and isinstance(subset, _LIST_TYPES) and not isinstance(subset, _STR_TYPES): + elif ( + isinstance(haystack, _LIST_TYPES) + and not isinstance(haystack, _STR_TYPES) + and isinstance(subset, _LIST_TYPES) + and not isinstance(subset, _STR_TYPES) + ): return _compare_sequence(haystack, subset, partial, strict) # for any other type, we just compare the two values. @@ -73,7 +77,12 @@ def _compare(haystack: Any, subset: Any, partial: bool, strict: bool) -> bool: return haystack == subset -def _compare_mapping(haystack: abc.Mapping, subset: abc.Mapping, partial: bool, strict: bool) -> bool: +def _compare_mapping( + haystack: abc.Mapping, + subset: abc.Mapping, + partial: bool, + strict: bool, +) -> bool: # check if all keys of the subset are also on the haystack object for key in subset.keys(): if key not in haystack: @@ -94,7 +103,12 @@ def _compare_mapping(haystack: abc.Mapping, subset: abc.Mapping, partial: bool, return True -def _compare_sequence(haystack: abc.Sequence, subset: abc.Sequence, partial: bool, strict: bool) -> bool: +def _compare_sequence( + haystack: abc.Sequence, + subset: abc.Sequence, + partial: bool, + strict: bool, +) -> bool: haystack_slice = haystack[:] # if we do not partially compare the lists, we need to check if the lengths of the two lists to compare are diff --git a/requirements.txt b/requirements.txt index b15a240..a18b468 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,9 +2,9 @@ -e . # Development dependencies -pytest>=8.3,<8.4 -flake8>=7.1,<7.2 codecov>=2.1,<2.2 +pre-commit>=4.0.1,<4.2 +pytest>=8.3,<8.4 setuptools>=75 -wheel>=0.44 twine>=5.1 +wheel>=0.44 diff --git a/setup.py b/setup.py index 4514763..40462ec 100644 --- a/setup.py +++ b/setup.py @@ -2,37 +2,37 @@ from setuptools import find_packages, setup -with open(os.path.join(os.path.dirname(__file__), 'README.md')) as fh: +with open(os.path.join(os.path.dirname(__file__), "README.md")) as fh: readme = fh.read() # allow setup.py to be run from any path os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( - name='deepcompare', - version=os.getenv('PACKAGE_VERSION', '0.0.0').replace('refs/tags/', ''), + name="deepcompare", + version=os.getenv("PACKAGE_VERSION", "0.0.0").replace("refs/tags/", ""), packages=find_packages(), include_package_data=True, - license='MIT', - description='A library for deep comparison of data structures consisting of `dict`, `list` and `tuple`.', + license="MIT", + description="A library for deep comparison of data structures consisting of `dict`, `list` and `tuple`.", long_description=readme, - long_description_content_type='text/markdown', - url='https://github.com/anexia/python-deepcompare', - author='Andreas Stocker', - author_email='AStocker@anexia-it.com', + long_description_content_type="text/markdown", + url="https://github.com/anexia/python-deepcompare", + author="Andreas Stocker", + author_email="AStocker@anexia-it.com", install_requires=[], classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Programming Language :: Python :: 3.13', - 'Topic :: Software Development', + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Topic :: Software Development", ], ) diff --git a/tests/test_compare_deep.py b/tests/test_compare_deep.py index 29695c0..0298f0b 100644 --- a/tests/test_compare_deep.py +++ b/tests/test_compare_deep.py @@ -3,109 +3,187 @@ def test_compare_list_in_list_with_list_in_list(): # test full equality - assert deepcompare.compare([[1, 2, ], 2, 3, ], [[1, 2, ], 2, 3, ]) - assert deepcompare.compare([[1, 2, ], [2, 3, ], 3, ], [[1, 2, ], [2, 3, ], 3, ]) - assert deepcompare.compare([[1, 2, ], [2, 3, ], [3, 4, ], ], [[1, 2, ], [2, 3, ], [3, 4, ], ]) + assert deepcompare.compare([[1, 2], 2, 3], [[1, 2], 2, 3]) + assert deepcompare.compare([[1, 2], [2, 3], 3], [[1, 2], [2, 3], 3]) + assert deepcompare.compare([[1, 2], [2, 3], [3, 4]], [[1, 2], [2, 3], [3, 4]]) # test partial equality - assert not deepcompare.compare([[1, 2, ], [2, 3, ], [3, 4, ], ], [[1, ], [2, 3, ], [3, 4, ], ]) - assert not deepcompare.compare([[1, 2, ], [2, 3, ], [3, 4, ], ], [[1, 2, ], [2, ], [3, 4, ], ]) - assert not deepcompare.compare([[1, 2, ], [2, 3, ], [3, 4, ], ], [[1, 2, ], [2, 3, ], [3, ], ]) - assert not deepcompare.compare([[1, 2, ], [2, 3, ], [3, 4, ], ], [[1, 2, ], [2, 3, ], ]) + assert not deepcompare.compare([[1, 2], [2, 3], [3, 4]], [[1], [2, 3], [3, 4]]) + assert not deepcompare.compare([[1, 2], [2, 3], [3, 4]], [[1, 2], [2], [3, 4]]) + assert not deepcompare.compare([[1, 2], [2, 3], [3, 4]], [[1, 2], [2, 3], [3]]) + assert not deepcompare.compare([[1, 2], [2, 3], [3, 4]], [[1, 2], [2, 3]]) # test non-equality - assert not deepcompare.compare([[1, 2, ], [2, 3, ], 3, ], [[1, 2, ], 2, 3, ]) - assert not deepcompare.compare([[1, 2, ], [2, 3, ], [3, 4, ], ], [[1, 2, ], 2, 3, ]) + assert not deepcompare.compare([[1, 2], [2, 3], 3], [[1, 2], 2, 3]) + assert not deepcompare.compare([[1, 2], [2, 3], [3, 4]], [[1, 2], 2, 3]) def test_compare_list_in_list_in_list_with_list_in_list_in_list(): # test full equality - assert deepcompare.compare([[[1, 2, ], 2, ], 2, 3, ], [[[1, 2, ], 2, ], 2, 3, ]) - assert deepcompare.compare([[[1, 2, ], 2, ], [[2, 3, ], 3, ], 3, ], [[[1, 2, ], 2, ], [[2, 3, ], 3, ], 3, ]) + assert deepcompare.compare([[[1, 2], 2], 2, 3], [[[1, 2], 2], 2, 3]) + assert deepcompare.compare( + [[[1, 2], 2], [[2, 3], 3], 3], + [[[1, 2], 2], [[2, 3], 3], 3], + ) # test partial equality - assert not deepcompare.compare([[[1, 2, ], 2, ], [[2, 3, ], 3, ], 3, ], [[[1, ], 2, ], [[2, 3, ], 3, ], 3, ]) - assert not deepcompare.compare([[[1, 2, ], 2, ], [[2, 3, ], 3, ], 3, ], [[[1, 2, ], 2, ], [[2, ], 3, ], 3, ]) - assert not deepcompare.compare([[[1, 2, ], 2, ], [[2, 3, ], 3, ], 3, ], [[[1, 2, ], 2, ], [[2, 3, ], ], 3, ]) + assert not deepcompare.compare( + [[[1, 2], 2], [[2, 3], 3], 3], + [[[1], 2], [[2, 3], 3], 3], + ) + assert not deepcompare.compare( + [[[1, 2], 2], [[2, 3], 3], 3], + [[[1, 2], 2], [[2], 3], 3], + ) + assert not deepcompare.compare( + [[[1, 2], 2], [[2, 3], 3], 3], + [[[1, 2], 2], [[2, 3]], 3], + ) # test non-equality - assert not deepcompare.compare([[[1, 2, ], 2, ], 2, 3, ], [[1, 2, ], 2, 3, ]) - assert not deepcompare.compare([[[1, 2, ], 2, ], [[2, 3], 3, ], 3, ], [[[1, 2, ], 2, ], [2, 3, ], 3, ]) + assert not deepcompare.compare([[[1, 2], 2], 2, 3], [[1, 2], 2, 3]) + assert not deepcompare.compare( + [[[1, 2], 2], [[2, 3], 3], 3], + [[[1, 2], 2], [2, 3], 3], + ) def test_compare_tuple_in_list_with_tuple_in_list(): # test full equality - assert deepcompare.compare([(1, 2, ), 2, 3, ], [(1, 2, ), 2, 3, ]) - assert deepcompare.compare([(1, 2, ), (2, 3, ), 3, ], [(1, 2, ), [2, 3, ], 3, ]) - assert deepcompare.compare([(1, 2, ), (2, 3, ), (3, 4, ), ], [(1, 2, ), (2, 3, ), (3, 4, ), ]) + assert deepcompare.compare([(1, 2), 2, 3], [(1, 2), 2, 3]) + assert deepcompare.compare([(1, 2), (2, 3), 3], [(1, 2), [2, 3], 3]) + assert deepcompare.compare([(1, 2), (2, 3), (3, 4)], [(1, 2), (2, 3), (3, 4)]) # test partial equality - assert not deepcompare.compare([(1, 2, ), (2, 3, ), (3, 4, ), ], [(1, ), (2, 3, ), (3, 4, ), ]) - assert not deepcompare.compare([(1, 2, ), (2, 3, ), (3, 4, ), ], [(1, 2, ), (2, ), (3, 4, ), ]) - assert not deepcompare.compare([(1, 2, ), (2, 3, ), (3, 4, ), ], [(1, 2, ), (2, 3, ), (3, ), ]) - assert not deepcompare.compare([(1, 2, ), (2, 3, ), (3, 4, ), ], [(1, 2, ), (2, 3, ), ]) + assert not deepcompare.compare([(1, 2), (2, 3), (3, 4)], [(1,), (2, 3), (3, 4)]) + assert not deepcompare.compare([(1, 2), (2, 3), (3, 4)], [(1, 2), (2,), (3, 4)]) + assert not deepcompare.compare([(1, 2), (2, 3), (3, 4)], [(1, 2), (2, 3), (3,)]) + assert not deepcompare.compare([(1, 2), (2, 3), (3, 4)], [(1, 2), (2, 3)]) # test non-equality - assert not deepcompare.compare([(1, 2, ), (2, 3, ), 3, ], [(1, 2, ), 2, 3, ]) - assert not deepcompare.compare([(1, 2, ), (2, 3, ), (3, 4, ), ], [(1, 2, ), 2, 3, ]) + assert not deepcompare.compare([(1, 2), (2, 3), 3], [(1, 2), 2, 3]) + assert not deepcompare.compare([(1, 2), (2, 3), (3, 4)], [(1, 2), 2, 3]) def test_compare_tuple_in_list_in_list_with_tuple_in_list_in_list(): # test full equality - assert deepcompare.compare([[(1, 2, ), 2, ], 2, 3, ], [[(1, 2, ), 2, ], 2, 3, ]) - assert deepcompare.compare([[(1, 2, ), 2, ], [(2, 3), 3, ], 3, ], [[(1, 2, ), 2, ], [(2, 3, ), 3, ], 3, ]) + assert deepcompare.compare([[(1, 2), 2], 2, 3], [[(1, 2), 2], 2, 3]) + assert deepcompare.compare( + [[(1, 2), 2], [(2, 3), 3], 3], + [[(1, 2), 2], [(2, 3), 3], 3], + ) # test partial equality - assert not deepcompare.compare([[(1, 2, ), 2, ], [(2, 3), 3, ], 3, ], [[(1, ), 2, ], [(2, 3, ), 3, ], 3, ]) - assert not deepcompare.compare([[(1, 2, ), 2, ], [(2, 3), 3, ], 3, ], [[(1, 2, ), 2, ], [(2, ), 3, ], 3, ]) - assert not deepcompare.compare([[(1, 2, ), 2, ], [(2, 3), 3, ], 3, ], [[(1, 2, ), 2, ], [(2, 3, ), 3, ], ]) + assert not deepcompare.compare( + [[(1, 2), 2], [(2, 3), 3], 3], + [[(1,), 2], [(2, 3), 3], 3], + ) + assert not deepcompare.compare( + [[(1, 2), 2], [(2, 3), 3], 3], + [[(1, 2), 2], [(2,), 3], 3], + ) + assert not deepcompare.compare( + [[(1, 2), 2], [(2, 3), 3], 3], + [[(1, 2), 2], [(2, 3), 3]], + ) # test non-equality - assert not deepcompare.compare([[(1, 2, ), 2, ], 2, 3, ], [(1, 2, ), 2, 3, ]) - assert not deepcompare.compare([[(1, 2, ), 2, ], [(2, 3), 3, ], 3, ], [[(1, 2, ), 2, ], [2, 3, ], 3, ]) + assert not deepcompare.compare([[(1, 2), 2], 2, 3], [(1, 2), 2, 3]) + assert not deepcompare.compare( + [[(1, 2), 2], [(2, 3), 3], 3], + [[(1, 2), 2], [2, 3], 3], + ) def test_compare_dict_in_list_with_dict_in_list(): # test full equality - assert deepcompare.compare([{'a': 1, 'b': 2, }, 2, 3, ], [{'a': 1, 'b': 2, }, 2, 3, ]) - assert deepcompare.compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, 3, ], [{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, 3, ]) - assert deepcompare.compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ], [{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ]) + assert deepcompare.compare([{"a": 1, "b": 2}, 2, 3], [{"a": 1, "b": 2}, 2, 3]) + assert deepcompare.compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, 3], + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, 3], + ) + assert deepcompare.compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + ) # test partial equality - assert not deepcompare.compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ], [{'a': 1, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ]) - assert not deepcompare.compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ], [{'a': 1, 'b': 2, }, {'c': 3, }, {'e': 5, 'f': 6, }, ]) - assert not deepcompare.compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ], [{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, }, ]) - assert not deepcompare.compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ], [{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, ]) + assert not deepcompare.compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + [{"a": 1}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + ) + assert not deepcompare.compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + [{"a": 1, "b": 2}, {"c": 3}, {"e": 5, "f": 6}], + ) + assert not deepcompare.compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5}], + ) + assert not deepcompare.compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + [{"a": 1, "b": 2}, {"c": 3, "d": 4}], + ) # test non-equality - assert not deepcompare.compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, 3, ], [{'a': 1, 'b': 2, }, 2, 3, ]) - assert not deepcompare.compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ], [{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, 3, ]) + assert not deepcompare.compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, 3], + [{"a": 1, "b": 2}, 2, 3], + ) + assert not deepcompare.compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, 3], + ) def test_compare_dict_in_list_in_list_with_dict_in_list_in_list(): # test full equality - assert deepcompare.compare([[{'a': 1, 'b': 2, }, 2, ], 2, 3, ], [[{'a': 1, 'b': 2, }, 2, ], 2, 3, ]) - assert deepcompare.compare([[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ], [[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ]) + assert deepcompare.compare( + [[{"a": 1, "b": 2}, 2], 2, 3], + [[{"a": 1, "b": 2}, 2], 2, 3], + ) + assert deepcompare.compare( + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3], 3], + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3], 3], + ) # test partial equality - assert not deepcompare.compare([[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ], [[{'a': 1, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ]) - assert not deepcompare.compare([[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ], [[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, }, 3, ], 3, ]) - assert not deepcompare.compare([[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ], [[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], ]) + assert not deepcompare.compare( + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3], 3], + [[{"a": 1}, 2], [{"c": 3, "d": 4}, 3], 3], + ) + assert not deepcompare.compare( + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3], 3], + [[{"a": 1, "b": 2}, 2], [{"c": 3}, 3], 3], + ) + assert not deepcompare.compare( + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3], 3], + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3]], + ) # test non-equality - assert not deepcompare.compare([[{'a': 1, 'b': 2, }, 2, ], 2, 3, ], [{'a': 1, 'b': 2, }, 2, 3, ]) - assert not deepcompare.compare([[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ], [[{'a': 1, 'b': 2, }, 2, ], [2, 3, ], 3, ]) + assert not deepcompare.compare( + [[{"a": 1, "b": 2}, 2], 2, 3], + [{"a": 1, "b": 2}, 2, 3], + ) + assert not deepcompare.compare( + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3], 3], + [[{"a": 1, "b": 2}, 2], [2, 3], 3], + ) def test_compare_list_in_dict(): # test full equality - assert deepcompare.compare({'a': [1, 2, ], 'b': 3, }, {'a': [1, 2, ], 'b': 3, }) - assert deepcompare.compare({'a': [1, 2, ], 'b': [3, 4, ], }, {'a': [1, 2, ], 'b': [3, 4, ], }) + assert deepcompare.compare({"a": [1, 2], "b": 3}, {"a": [1, 2], "b": 3}) + assert deepcompare.compare({"a": [1, 2], "b": [3, 4]}, {"a": [1, 2], "b": [3, 4]}) # test partial equality - assert not deepcompare.compare({'a': [1, 2, ], 'b': 3, }, {'a': [1, 2, ], }) - assert not deepcompare.compare({'a': [1, 2, ], 'b': [3, 4, ], }, {'a': [1, 2, ], 'b': [3, ], }) + assert not deepcompare.compare({"a": [1, 2], "b": 3}, {"a": [1, 2]}) + assert not deepcompare.compare({"a": [1, 2], "b": [3, 4]}, {"a": [1, 2], "b": [3]}) # test non-equality - assert not deepcompare.compare({'a': [1, 2, ], 'b': [3, 4, ], }, {'a': [1, 2, ], 'b': 3, }) - assert not deepcompare.compare({'a': [1, 2, ], 'b': [3, 4, ], }, {'a': [1, 2, ], 'b': [3, 4, 5, ], }) + assert not deepcompare.compare({"a": [1, 2], "b": [3, 4]}, {"a": [1, 2], "b": 3}) + assert not deepcompare.compare( + {"a": [1, 2], "b": [3, 4]}, + {"a": [1, 2], "b": [3, 4, 5]}, + ) diff --git a/tests/test_compare_flat.py b/tests/test_compare_flat.py index 3363c66..b490456 100644 --- a/tests/test_compare_flat.py +++ b/tests/test_compare_flat.py @@ -3,156 +3,167 @@ def test_compare_str_with_str(): # test full equality - assert deepcompare.compare('abc', 'abc') + assert deepcompare.compare("abc", "abc") # test non-equality - assert not deepcompare.compare('abc', 'a') - assert not deepcompare.compare('abc', 'ab') - assert not deepcompare.compare('abc', 'abcd') + assert not deepcompare.compare("abc", "a") + assert not deepcompare.compare("abc", "ab") + assert not deepcompare.compare("abc", "abcd") def test_compare_str_in_list_with_str_in_list(): # test full equality - assert deepcompare.compare(['a', 'b', 'c', ], ['a', 'b', 'c', ]) + assert deepcompare.compare(["a", "b", "c"], ["a", "b", "c"]) # test partial equality - assert not deepcompare.compare(['a', 'b', 'c', ], ['a', ]) - assert not deepcompare.compare(['a', 'b', 'c', ], ['a', 'b', ]) - assert not deepcompare.compare(['a', 'b', 'c', ], ['a', 'c', ]) + assert not deepcompare.compare(["a", "b", "c"], ["a"]) + assert not deepcompare.compare(["a", "b", "c"], ["a", "b"]) + assert not deepcompare.compare(["a", "b", "c"], ["a", "c"]) # test non-equality - assert not deepcompare.compare(['a', 'b', 'c', ], ['c', 'b', 'a', ]) - assert not deepcompare.compare(['a', 'b', 'c', ], ['a', 'c', 'b', ]) - assert not deepcompare.compare(['a', 'b', 'c', ], ['a', 'b', 'c', 'd', ]) + assert not deepcompare.compare(["a", "b", "c"], ["c", "b", "a"]) + assert not deepcompare.compare(["a", "b", "c"], ["a", "c", "b"]) + assert not deepcompare.compare(["a", "b", "c"], ["a", "b", "c", "d"]) def test_compare_list_with_list(): # test full equality - assert deepcompare.compare([1, 2, 3, ], [1, 2, 3, ]) + assert deepcompare.compare([1, 2, 3], [1, 2, 3]) # test partial equality - assert not deepcompare.compare([1, 2, 3, ], [1, ]) - assert not deepcompare.compare([1, 2, 3, ], [1, 2, ]) - assert not deepcompare.compare([1, 2, 3, ], [1, 3, ]) + assert not deepcompare.compare([1, 2, 3], [1]) + assert not deepcompare.compare([1, 2, 3], [1, 2]) + assert not deepcompare.compare([1, 2, 3], [1, 3]) # test non-equality - assert not deepcompare.compare([1, 2, 3, ], [3, 2, 1, ]) - assert not deepcompare.compare([1, 2, 3, ], [2, 3, 1, ]) - assert not deepcompare.compare([1, 2, 3, ], [1, 2, 3, 4, ]) + assert not deepcompare.compare([1, 2, 3], [3, 2, 1]) + assert not deepcompare.compare([1, 2, 3], [2, 3, 1]) + assert not deepcompare.compare([1, 2, 3], [1, 2, 3, 4]) def test_compare_tuple_with_tuple(): # test full equality - assert deepcompare.compare((1, 2, 3, ), (1, 2, 3, )) + assert deepcompare.compare((1, 2, 3), (1, 2, 3)) # test partial equality - assert not deepcompare.compare((1, 2, 3, ), (1, )) - assert not deepcompare.compare((1, 2, 3, ), (1, 2, )) - assert not deepcompare.compare((1, 2, 3, ), (1, 3, )) + assert not deepcompare.compare((1, 2, 3), (1,)) + assert not deepcompare.compare((1, 2, 3), (1, 2)) + assert not deepcompare.compare((1, 2, 3), (1, 3)) # test non-equality - assert not deepcompare.compare((1, 2, 3, ), (3, 2, 1, )) - assert not deepcompare.compare((1, 2, 3, ), (2, 3, 1, )) - assert not deepcompare.compare((1, 2, 3, ), (1, 2, 3, 4, )) + assert not deepcompare.compare((1, 2, 3), (3, 2, 1)) + assert not deepcompare.compare((1, 2, 3), (2, 3, 1)) + assert not deepcompare.compare((1, 2, 3), (1, 2, 3, 4)) def test_compare_dict_with_dict(): # test full equality - assert deepcompare.compare({'a': 1, 'b': 2, 'c': 3, }, {'a': 1, 'b': 2, 'c': 3, }) + assert deepcompare.compare({"a": 1, "b": 2, "c": 3}, {"a": 1, "b": 2, "c": 3}) # test partial equality - assert not deepcompare.compare({'a': 1, 'b': 2, 'c': 3, }, {'a': 1, 'b': 2, }) + assert not deepcompare.compare({"a": 1, "b": 2, "c": 3}, {"a": 1, "b": 2}) # test non-equality - assert not deepcompare.compare({'a': 1, 'b': 2, 'c': 3, }, {'a': 1, 'b': 2, 'c': 3, 'd': 4, }) + assert not deepcompare.compare( + {"a": 1, "b": 2, "c": 3}, + {"a": 1, "b": 2, "c": 3, "d": 4}, + ) def test_compare_list_with_tuple_non_strict(): # test full equality - assert deepcompare.compare([1, 2, 3, ], (1, 2, 3, )) + assert deepcompare.compare([1, 2, 3], (1, 2, 3)) # test partial equality - assert not deepcompare.compare([1, 2, 3, ], (1,)) - assert not deepcompare.compare([1, 2, 3, ], (1, 2,)) - assert not deepcompare.compare([1, 2, 3, ], (1, 3,)) + assert not deepcompare.compare([1, 2, 3], (1,)) + assert not deepcompare.compare([1, 2, 3], (1, 2)) + assert not deepcompare.compare([1, 2, 3], (1, 3)) # test non-equality - assert not deepcompare.compare([1, 2, 3, ], (3, 2, 1, )) - assert not deepcompare.compare([1, 2, 3, ], (2, 3, 1, )) - assert not deepcompare.compare([1, 2, 3, ], (1, 2, 3, 4, )) + assert not deepcompare.compare([1, 2, 3], (3, 2, 1)) + assert not deepcompare.compare([1, 2, 3], (2, 3, 1)) + assert not deepcompare.compare([1, 2, 3], (1, 2, 3, 4)) def test_compare_list_with_tuple_strict(): # test full equality with type mismatch - assert not deepcompare.compare([1, 2, 3, ], (1, 2, 3, ), strict=True) + assert not deepcompare.compare([1, 2, 3], (1, 2, 3), strict=True) # test partial equality with type mismatch - assert not deepcompare.compare([1, 2, 3, ], (1,), strict=True) - assert not deepcompare.compare([1, 2, 3, ], (1, 2,), strict=True) - assert not deepcompare.compare([1, 2, 3, ], (1, 3,), strict=True) + assert not deepcompare.compare([1, 2, 3], (1,), strict=True) + assert not deepcompare.compare([1, 2, 3], (1, 2), strict=True) + assert not deepcompare.compare([1, 2, 3], (1, 3), strict=True) # test non-equality with type mismatch - assert not deepcompare.compare([1, 2, 3, ], (3, 2, 1, ), strict=True) - assert not deepcompare.compare([1, 2, 3, ], (2, 3, 1, ), strict=True) - assert not deepcompare.compare([1, 2, 3, ], (1, 2, 3, 4, ), strict=True) + assert not deepcompare.compare([1, 2, 3], (3, 2, 1), strict=True) + assert not deepcompare.compare([1, 2, 3], (2, 3, 1), strict=True) + assert not deepcompare.compare([1, 2, 3], (1, 2, 3, 4), strict=True) def test_compare_tuple_with_list_non_strict(): # test full equality - assert deepcompare.compare((1, 2, 3, ), [1, 2, 3, ]) + assert deepcompare.compare((1, 2, 3), [1, 2, 3]) # test partial equality - assert not deepcompare.compare((1, 2, 3,), [1, ]) - assert not deepcompare.compare((1, 2, 3,), [1, 2, ]) - assert not deepcompare.compare((1, 2, 3,), [1, 3, ]) + assert not deepcompare.compare((1, 2, 3), [1]) + assert not deepcompare.compare((1, 2, 3), [1, 2]) + assert not deepcompare.compare((1, 2, 3), [1, 3]) # test non-equality - assert not deepcompare.compare((1, 2, 3, ), [3, 2, 1, ]) - assert not deepcompare.compare((1, 2, 3, ), [2, 3, 1, ]) - assert not deepcompare.compare((1, 2, 3, ), [1, 2, 3, 4, ]) + assert not deepcompare.compare((1, 2, 3), [3, 2, 1]) + assert not deepcompare.compare((1, 2, 3), [2, 3, 1]) + assert not deepcompare.compare((1, 2, 3), [1, 2, 3, 4]) def test_compare_tuple_with_list_strict(): # test full equality with type mismatch - assert not deepcompare.compare((1, 2, 3, ), [1, 2, 3, ], strict=True) + assert not deepcompare.compare((1, 2, 3), [1, 2, 3], strict=True) # test partial equality with type mismatch - assert not deepcompare.compare((1, 2, 3,), [1, ], strict=True) - assert not deepcompare.compare((1, 2, 3,), [1, 2, ], strict=True) - assert not deepcompare.compare((1, 2, 3,), [1, 3, ], strict=True) + assert not deepcompare.compare((1, 2, 3), [1], strict=True) + assert not deepcompare.compare((1, 2, 3), [1, 2], strict=True) + assert not deepcompare.compare((1, 2, 3), [1, 3], strict=True) # test non-equality with type mismatch - assert not deepcompare.compare((1, 2, 3, ), [3, 2, 1, ], strict=True) - assert not deepcompare.compare((1, 2, 3, ), [2, 3, 1, ], strict=True) - assert not deepcompare.compare((1, 2, 3, ), [1, 2, 3, 4, ], strict=True) + assert not deepcompare.compare((1, 2, 3), [3, 2, 1], strict=True) + assert not deepcompare.compare((1, 2, 3), [2, 3, 1], strict=True) + assert not deepcompare.compare((1, 2, 3), [1, 2, 3, 4], strict=True) def test_compare_list_with_dict_non_strict(): # test non-equality - assert not deepcompare.compare([1, 2, 3, ], {'a': 1, 'b': 2, 'c': 3, }) - assert not deepcompare.compare([1, 2, 3, ], {'a': 1, 'b': 2, }) - assert not deepcompare.compare([1, 2, 3, ], {'a': 1, 'b': 2, 'c': 3, 'd': 4, }) + assert not deepcompare.compare([1, 2, 3], {"a": 1, "b": 2, "c": 3}) + assert not deepcompare.compare([1, 2, 3], {"a": 1, "b": 2}) + assert not deepcompare.compare([1, 2, 3], {"a": 1, "b": 2, "c": 3, "d": 4}) def test_compare_list_with_dict_strict(): # test non-equality with type mismatch - assert not deepcompare.compare([1, 2, 3, ], {'a': 1, 'b': 2, 'c': 3, }, strict=True) - assert not deepcompare.compare([1, 2, 3, ], {'a': 1, 'b': 2, }, strict=True) - assert not deepcompare.compare([1, 2, 3, ], {'a': 1, 'b': 2, 'c': 3, 'd': 4, }, strict=True) + assert not deepcompare.compare([1, 2, 3], {"a": 1, "b": 2, "c": 3}, strict=True) + assert not deepcompare.compare([1, 2, 3], {"a": 1, "b": 2}, strict=True) + assert not deepcompare.compare( + [1, 2, 3], + {"a": 1, "b": 2, "c": 3, "d": 4}, + strict=True, + ) def test_compare_tuple_with_dict_non_strict(): # test non-equality - assert not deepcompare.compare((1, 2, 3, ), {'a': 1, 'b': 2, 'c': 3, }) - assert not deepcompare.compare((1, 2, 3, ), {'a': 1, 'b': 2, }) - assert not deepcompare.compare((1, 2, 3, ), {'a': 1, 'b': 2, 'c': 3, 'd': 4, }) + assert not deepcompare.compare((1, 2, 3), {"a": 1, "b": 2, "c": 3}) + assert not deepcompare.compare((1, 2, 3), {"a": 1, "b": 2}) + assert not deepcompare.compare((1, 2, 3), {"a": 1, "b": 2, "c": 3, "d": 4}) def test_compare_tuple_with_dict_strict(): # test non-equality with type mismatch - assert not deepcompare.compare((1, 2, 3, ), {'a': 1, 'b': 2, 'c': 3, }, strict=True) - assert not deepcompare.compare((1, 2, 3, ), {'a': 1, 'b': 2, }, strict=True) - assert not deepcompare.compare((1, 2, 3, ), {'a': 1, 'b': 2, 'c': 3, 'd': 4, }, strict=True) + assert not deepcompare.compare((1, 2, 3), {"a": 1, "b": 2, "c": 3}, strict=True) + assert not deepcompare.compare((1, 2, 3), {"a": 1, "b": 2}, strict=True) + assert not deepcompare.compare( + (1, 2, 3), + {"a": 1, "b": 2, "c": 3, "d": 4}, + strict=True, + ) def test_compare_with_none_non_strict(): @@ -160,9 +171,9 @@ def test_compare_with_none_non_strict(): assert deepcompare.compare(None, None) # test non-equality - assert not deepcompare.compare(None, [1, 2, 3, ]) - assert not deepcompare.compare(None, (1, 2, 3, )) - assert not deepcompare.compare(None, {'a': 1, 'b': 2, 'c': 3, }) + assert not deepcompare.compare(None, [1, 2, 3]) + assert not deepcompare.compare(None, (1, 2, 3)) + assert not deepcompare.compare(None, {"a": 1, "b": 2, "c": 3}) def test_compare_with_none_strict(): @@ -170,6 +181,6 @@ def test_compare_with_none_strict(): assert deepcompare.compare(None, None, strict=True) # test non-equality - assert not deepcompare.compare(None, [1, 2, 3, ], strict=True) - assert not deepcompare.compare(None, (1, 2, 3, ), strict=True) - assert not deepcompare.compare(None, {'a': 1, 'b': 2, 'c': 3, }, strict=True) + assert not deepcompare.compare(None, [1, 2, 3], strict=True) + assert not deepcompare.compare(None, (1, 2, 3), strict=True) + assert not deepcompare.compare(None, {"a": 1, "b": 2, "c": 3}, strict=True) diff --git a/tests/test_partial_compare_deep.py b/tests/test_partial_compare_deep.py index 49f2575..ae3b4f6 100644 --- a/tests/test_partial_compare_deep.py +++ b/tests/test_partial_compare_deep.py @@ -3,109 +3,205 @@ def test_compare_list_in_list_with_list_in_list(): # test full equality - assert deepcompare.partial_compare([[1, 2, ], 2, 3, ], [[1, 2, ], 2, 3, ]) - assert deepcompare.partial_compare([[1, 2, ], [2, 3, ], 3, ], [[1, 2, ], [2, 3, ], 3, ]) - assert deepcompare.partial_compare([[1, 2, ], [2, 3, ], [3, 4, ], ], [[1, 2, ], [2, 3, ], [3, 4, ], ]) + assert deepcompare.partial_compare([[1, 2], 2, 3], [[1, 2], 2, 3]) + assert deepcompare.partial_compare([[1, 2], [2, 3], 3], [[1, 2], [2, 3], 3]) + assert deepcompare.partial_compare( + [[1, 2], [2, 3], [3, 4]], + [[1, 2], [2, 3], [3, 4]], + ) # test partial equality - assert deepcompare.partial_compare([[1, 2, ], [2, 3, ], [3, 4, ], ], [[1, ], [2, 3, ], [3, 4, ], ]) - assert deepcompare.partial_compare([[1, 2, ], [2, 3, ], [3, 4, ], ], [[1, 2, ], [2, ], [3, 4, ], ]) - assert deepcompare.partial_compare([[1, 2, ], [2, 3, ], [3, 4, ], ], [[1, 2, ], [2, 3, ], [3, ], ]) - assert deepcompare.partial_compare([[1, 2, ], [2, 3, ], [3, 4, ], ], [[1, 2, ], [2, 3, ], ]) + assert deepcompare.partial_compare([[1, 2], [2, 3], [3, 4]], [[1], [2, 3], [3, 4]]) + assert deepcompare.partial_compare([[1, 2], [2, 3], [3, 4]], [[1, 2], [2], [3, 4]]) + assert deepcompare.partial_compare([[1, 2], [2, 3], [3, 4]], [[1, 2], [2, 3], [3]]) + assert deepcompare.partial_compare([[1, 2], [2, 3], [3, 4]], [[1, 2], [2, 3]]) # test non-equality - assert not deepcompare.partial_compare([[1, 2, ], [2, 3, ], 3, ], [[1, 2, ], 2, 3, ]) - assert not deepcompare.partial_compare([[1, 2, ], [2, 3, ], [3, 4, ], ], [[1, 2, ], 2, 3, ]) + assert not deepcompare.partial_compare([[1, 2], [2, 3], 3], [[1, 2], 2, 3]) + assert not deepcompare.partial_compare([[1, 2], [2, 3], [3, 4]], [[1, 2], 2, 3]) def test_compare_list_in_list_in_list_with_list_in_list_in_list(): # test full equality - assert deepcompare.partial_compare([[[1, 2, ], 2, ], 2, 3, ], [[[1, 2, ], 2, ], 2, 3, ]) - assert deepcompare.partial_compare([[[1, 2, ], 2, ], [[2, 3, ], 3, ], 3, ], [[[1, 2, ], 2, ], [[2, 3, ], 3, ], 3, ]) + assert deepcompare.partial_compare([[[1, 2], 2], 2, 3], [[[1, 2], 2], 2, 3]) + assert deepcompare.partial_compare( + [[[1, 2], 2], [[2, 3], 3], 3], + [[[1, 2], 2], [[2, 3], 3], 3], + ) # test partial equality - assert deepcompare.partial_compare([[[1, 2, ], 2, ], [[2, 3, ], 3, ], 3, ], [[[1, ], 2, ], [[2, 3, ], 3, ], 3, ]) - assert deepcompare.partial_compare([[[1, 2, ], 2, ], [[2, 3, ], 3, ], 3, ], [[[1, 2, ], 2, ], [[2, ], 3, ], 3, ]) - assert deepcompare.partial_compare([[[1, 2, ], 2, ], [[2, 3, ], 3, ], 3, ], [[[1, 2, ], 2, ], [[2, 3, ], ], 3, ]) + assert deepcompare.partial_compare( + [[[1, 2], 2], [[2, 3], 3], 3], + [[[1], 2], [[2, 3], 3], 3], + ) + assert deepcompare.partial_compare( + [[[1, 2], 2], [[2, 3], 3], 3], + [[[1, 2], 2], [[2], 3], 3], + ) + assert deepcompare.partial_compare( + [[[1, 2], 2], [[2, 3], 3], 3], + [[[1, 2], 2], [[2, 3]], 3], + ) # test non-equality - assert not deepcompare.partial_compare([[[1, 2, ], 2, ], 2, 3, ], [[1, 2, ], 2, 3, ]) - assert not deepcompare.partial_compare([[[1, 2, ], 2, ], [[2, 3], 3, ], 3, ], [[[1, 2, ], 2, ], [2, 3, ], 3, ]) + assert not deepcompare.partial_compare([[[1, 2], 2], 2, 3], [[1, 2], 2, 3]) + assert not deepcompare.partial_compare( + [[[1, 2], 2], [[2, 3], 3], 3], + [[[1, 2], 2], [2, 3], 3], + ) def test_compare_tuple_in_list_with_tuple_in_list(): # test full equality - assert deepcompare.partial_compare([(1, 2, ), 2, 3, ], [(1, 2, ), 2, 3, ]) - assert deepcompare.partial_compare([(1, 2, ), (2, 3, ), 3, ], [(1, 2, ), [2, 3, ], 3, ]) - assert deepcompare.partial_compare([(1, 2, ), (2, 3, ), (3, 4, ), ], [(1, 2, ), (2, 3, ), (3, 4, ), ]) + assert deepcompare.partial_compare([(1, 2), 2, 3], [(1, 2), 2, 3]) + assert deepcompare.partial_compare([(1, 2), (2, 3), 3], [(1, 2), [2, 3], 3]) + assert deepcompare.partial_compare( + [(1, 2), (2, 3), (3, 4)], + [(1, 2), (2, 3), (3, 4)], + ) # test partial equality - assert deepcompare.partial_compare([(1, 2, ), (2, 3, ), (3, 4, ), ], [(1, ), (2, 3, ), (3, 4, ), ]) - assert deepcompare.partial_compare([(1, 2, ), (2, 3, ), (3, 4, ), ], [(1, 2, ), (2, ), (3, 4, ), ]) - assert deepcompare.partial_compare([(1, 2, ), (2, 3, ), (3, 4, ), ], [(1, 2, ), (2, 3, ), (3, ), ]) - assert deepcompare.partial_compare([(1, 2, ), (2, 3, ), (3, 4, ), ], [(1, 2, ), (2, 3, ), ]) + assert deepcompare.partial_compare([(1, 2), (2, 3), (3, 4)], [(1,), (2, 3), (3, 4)]) + assert deepcompare.partial_compare([(1, 2), (2, 3), (3, 4)], [(1, 2), (2,), (3, 4)]) + assert deepcompare.partial_compare([(1, 2), (2, 3), (3, 4)], [(1, 2), (2, 3), (3,)]) + assert deepcompare.partial_compare([(1, 2), (2, 3), (3, 4)], [(1, 2), (2, 3)]) # test non-equality - assert not deepcompare.partial_compare([(1, 2, ), (2, 3, ), 3, ], [(1, 2, ), 2, 3, ]) - assert not deepcompare.partial_compare([(1, 2, ), (2, 3, ), (3, 4, ), ], [(1, 2, ), 2, 3, ]) + assert not deepcompare.partial_compare([(1, 2), (2, 3), 3], [(1, 2), 2, 3]) + assert not deepcompare.partial_compare([(1, 2), (2, 3), (3, 4)], [(1, 2), 2, 3]) def test_compare_tuple_in_list_in_list_with_tuple_in_list_in_list(): # test full equality - assert deepcompare.partial_compare([[(1, 2, ), 2, ], 2, 3, ], [[(1, 2, ), 2, ], 2, 3, ]) - assert deepcompare.partial_compare([[(1, 2, ), 2, ], [(2, 3), 3, ], 3, ], [[(1, 2, ), 2, ], [(2, 3, ), 3, ], 3, ]) + assert deepcompare.partial_compare([[(1, 2), 2], 2, 3], [[(1, 2), 2], 2, 3]) + assert deepcompare.partial_compare( + [[(1, 2), 2], [(2, 3), 3], 3], + [[(1, 2), 2], [(2, 3), 3], 3], + ) # test partial equality - assert deepcompare.partial_compare([[(1, 2, ), 2, ], [(2, 3), 3, ], 3, ], [[(1, ), 2, ], [(2, 3, ), 3, ], 3, ]) - assert deepcompare.partial_compare([[(1, 2, ), 2, ], [(2, 3), 3, ], 3, ], [[(1, 2, ), 2, ], [(2, ), 3, ], 3, ]) - assert deepcompare.partial_compare([[(1, 2, ), 2, ], [(2, 3), 3, ], 3, ], [[(1, 2, ), 2, ], [(2, 3, ), 3, ], ]) + assert deepcompare.partial_compare( + [[(1, 2), 2], [(2, 3), 3], 3], + [[(1,), 2], [(2, 3), 3], 3], + ) + assert deepcompare.partial_compare( + [[(1, 2), 2], [(2, 3), 3], 3], + [[(1, 2), 2], [(2,), 3], 3], + ) + assert deepcompare.partial_compare( + [[(1, 2), 2], [(2, 3), 3], 3], + [[(1, 2), 2], [(2, 3), 3]], + ) # test non-equality - assert not deepcompare.partial_compare([[(1, 2, ), 2, ], 2, 3, ], [(1, 2, ), 2, 3, ]) - assert not deepcompare.partial_compare([[(1, 2, ), 2, ], [(2, 3), 3, ], 3, ], [[(1, 2, ), 2, ], [2, 3, ], 3, ]) + assert not deepcompare.partial_compare([[(1, 2), 2], 2, 3], [(1, 2), 2, 3]) + assert not deepcompare.partial_compare( + [[(1, 2), 2], [(2, 3), 3], 3], + [[(1, 2), 2], [2, 3], 3], + ) def test_compare_dict_in_list_with_dict_in_list(): # test full equality - assert deepcompare.partial_compare([{'a': 1, 'b': 2, }, 2, 3, ], [{'a': 1, 'b': 2, }, 2, 3, ]) - assert deepcompare.partial_compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, 3, ], [{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, 3, ]) - assert deepcompare.partial_compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ], [{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ]) + assert deepcompare.partial_compare( + [{"a": 1, "b": 2}, 2, 3], + [{"a": 1, "b": 2}, 2, 3], + ) + assert deepcompare.partial_compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, 3], + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, 3], + ) + assert deepcompare.partial_compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + ) # test partial equality - assert deepcompare.partial_compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ], [{'a': 1, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ]) - assert deepcompare.partial_compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ], [{'a': 1, 'b': 2, }, {'c': 3, }, {'e': 5, 'f': 6, }, ]) - assert deepcompare.partial_compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ], [{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, }, ]) - assert deepcompare.partial_compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ], [{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, ]) + assert deepcompare.partial_compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + [{"a": 1}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + ) + assert deepcompare.partial_compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + [{"a": 1, "b": 2}, {"c": 3}, {"e": 5, "f": 6}], + ) + assert deepcompare.partial_compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5}], + ) + assert deepcompare.partial_compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + [{"a": 1, "b": 2}, {"c": 3, "d": 4}], + ) # test non-equality - assert not deepcompare.partial_compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, 3, ], [{'a': 1, 'b': 2, }, 2, 3, ]) - assert not deepcompare.partial_compare([{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, {'e': 5, 'f': 6, }, ], [{'a': 1, 'b': 2, }, {'c': 3, 'd': 4, }, 3, ]) + assert not deepcompare.partial_compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, 3], + [{"a": 1, "b": 2}, 2, 3], + ) + assert not deepcompare.partial_compare( + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5, "f": 6}], + [{"a": 1, "b": 2}, {"c": 3, "d": 4}, 3], + ) def test_compare_dict_in_list_in_list_with_dict_in_list_in_list(): # test full equality - assert deepcompare.partial_compare([[{'a': 1, 'b': 2, }, 2, ], 2, 3, ], [[{'a': 1, 'b': 2, }, 2, ], 2, 3, ]) - assert deepcompare.partial_compare([[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ], [[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ]) + assert deepcompare.partial_compare( + [[{"a": 1, "b": 2}, 2], 2, 3], + [[{"a": 1, "b": 2}, 2], 2, 3], + ) + assert deepcompare.partial_compare( + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3], 3], + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3], 3], + ) # test partial equality - assert deepcompare.partial_compare([[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ], [[{'a': 1, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ]) - assert deepcompare.partial_compare([[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ], [[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, }, 3, ], 3, ]) - assert deepcompare.partial_compare([[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ], [[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], ]) + assert deepcompare.partial_compare( + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3], 3], + [[{"a": 1}, 2], [{"c": 3, "d": 4}, 3], 3], + ) + assert deepcompare.partial_compare( + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3], 3], + [[{"a": 1, "b": 2}, 2], [{"c": 3}, 3], 3], + ) + assert deepcompare.partial_compare( + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3], 3], + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3]], + ) # test non-equality - assert not deepcompare.partial_compare([[{'a': 1, 'b': 2, }, 2, ], 2, 3, ], [{'a': 1, 'b': 2, }, 2, 3, ]) - assert not deepcompare.partial_compare([[{'a': 1, 'b': 2, }, 2, ], [{'c': 3, 'd': 4, }, 3, ], 3, ], [[{'a': 1, 'b': 2, }, 2, ], [2, 3, ], 3, ]) + assert not deepcompare.partial_compare( + [[{"a": 1, "b": 2}, 2], 2, 3], + [{"a": 1, "b": 2}, 2, 3], + ) + assert not deepcompare.partial_compare( + [[{"a": 1, "b": 2}, 2], [{"c": 3, "d": 4}, 3], 3], + [[{"a": 1, "b": 2}, 2], [2, 3], 3], + ) def test_compare_list_in_dict(): # test full equality - assert deepcompare.partial_compare({'a': [1, 2, ], 'b': 3, }, {'a': [1, 2, ], 'b': 3, }) - assert deepcompare.partial_compare({'a': [1, 2, ], 'b': [3, 4, ], }, {'a': [1, 2, ], 'b': [3, 4, ], }) + assert deepcompare.partial_compare({"a": [1, 2], "b": 3}, {"a": [1, 2], "b": 3}) + assert deepcompare.partial_compare( + {"a": [1, 2], "b": [3, 4]}, + {"a": [1, 2], "b": [3, 4]}, + ) # test partial equality - assert deepcompare.partial_compare({'a': [1, 2, ], 'b': 3, }, {'a': [1, 2, ], }) - assert deepcompare.partial_compare({'a': [1, 2, ], 'b': [3, 4, ], }, {'a': [1, 2, ], 'b': [3, ], }) + assert deepcompare.partial_compare({"a": [1, 2], "b": 3}, {"a": [1, 2]}) + assert deepcompare.partial_compare( + {"a": [1, 2], "b": [3, 4]}, + {"a": [1, 2], "b": [3]}, + ) # test non-equality - assert not deepcompare.partial_compare({'a': [1, 2, ], 'b': [3, 4, ], }, {'a': [1, 2, ], 'b': 3, }) - assert not deepcompare.partial_compare({'a': [1, 2, ], 'b': [3, 4, ], }, {'a': [1, 2, ], 'b': [3, 4, 5, ], }) + assert not deepcompare.partial_compare( + {"a": [1, 2], "b": [3, 4]}, + {"a": [1, 2], "b": 3}, + ) + assert not deepcompare.partial_compare( + {"a": [1, 2], "b": [3, 4]}, + {"a": [1, 2], "b": [3, 4, 5]}, + ) diff --git a/tests/test_partial_compare_flat.py b/tests/test_partial_compare_flat.py index 5cb71ee..39eae7e 100644 --- a/tests/test_partial_compare_flat.py +++ b/tests/test_partial_compare_flat.py @@ -3,156 +3,178 @@ def test_compare_str_with_str(): # test full equality - assert deepcompare.partial_compare('abc', 'abc') + assert deepcompare.partial_compare("abc", "abc") # test non-equality - assert not deepcompare.partial_compare('abc', 'a') - assert not deepcompare.partial_compare('abc', 'ab') - assert not deepcompare.partial_compare('abc', 'abcd') + assert not deepcompare.partial_compare("abc", "a") + assert not deepcompare.partial_compare("abc", "ab") + assert not deepcompare.partial_compare("abc", "abcd") def test_compare_str_in_list_with_str_in_list(): # test full equality - assert deepcompare.partial_compare(['a', 'b', 'c', ], ['a', 'b', 'c', ]) + assert deepcompare.partial_compare(["a", "b", "c"], ["a", "b", "c"]) # test partial equality - assert deepcompare.partial_compare(['a', 'b', 'c', ], ['a', ]) - assert deepcompare.partial_compare(['a', 'b', 'c', ], ['a', 'b', ]) - assert deepcompare.partial_compare(['a', 'b', 'c', ], ['a', 'c', ]) + assert deepcompare.partial_compare(["a", "b", "c"], ["a"]) + assert deepcompare.partial_compare(["a", "b", "c"], ["a", "b"]) + assert deepcompare.partial_compare(["a", "b", "c"], ["a", "c"]) # test non-equality - assert not deepcompare.partial_compare(['a', 'b', 'c', ], ['c', 'b', 'a', ]) - assert not deepcompare.partial_compare(['a', 'b', 'c', ], ['a', 'c', 'b', ]) - assert not deepcompare.partial_compare(['a', 'b', 'c', ], ['a', 'b', 'c', 'd', ]) + assert not deepcompare.partial_compare(["a", "b", "c"], ["c", "b", "a"]) + assert not deepcompare.partial_compare(["a", "b", "c"], ["a", "c", "b"]) + assert not deepcompare.partial_compare(["a", "b", "c"], ["a", "b", "c", "d"]) def test_compare_list_with_list(): # test full equality - assert deepcompare.partial_compare([1, 2, 3, ], [1, 2, 3, ]) + assert deepcompare.partial_compare([1, 2, 3], [1, 2, 3]) # test partial equality - assert deepcompare.partial_compare([1, 2, 3, ], [1, ]) - assert deepcompare.partial_compare([1, 2, 3, ], [1, 2, ]) - assert deepcompare.partial_compare([1, 2, 3, ], [1, 3, ]) + assert deepcompare.partial_compare([1, 2, 3], [1]) + assert deepcompare.partial_compare([1, 2, 3], [1, 2]) + assert deepcompare.partial_compare([1, 2, 3], [1, 3]) # test non-equality - assert not deepcompare.partial_compare([1, 2, 3, ], [3, 2, 1, ]) - assert not deepcompare.partial_compare([1, 2, 3, ], [2, 3, 1, ]) - assert not deepcompare.partial_compare([1, 2, 3, ], [1, 2, 3, 4, ]) + assert not deepcompare.partial_compare([1, 2, 3], [3, 2, 1]) + assert not deepcompare.partial_compare([1, 2, 3], [2, 3, 1]) + assert not deepcompare.partial_compare([1, 2, 3], [1, 2, 3, 4]) def test_compare_tuple_with_tuple(): # test full equality - assert deepcompare.partial_compare((1, 2, 3, ), (1, 2, 3, )) + assert deepcompare.partial_compare((1, 2, 3), (1, 2, 3)) # test partial equality - assert deepcompare.partial_compare((1, 2, 3, ), (1, )) - assert deepcompare.partial_compare((1, 2, 3, ), (1, 2, )) - assert deepcompare.partial_compare((1, 2, 3, ), (1, 3, )) + assert deepcompare.partial_compare((1, 2, 3), (1,)) + assert deepcompare.partial_compare((1, 2, 3), (1, 2)) + assert deepcompare.partial_compare((1, 2, 3), (1, 3)) # test non-equality - assert not deepcompare.partial_compare((1, 2, 3, ), (3, 2, 1, )) - assert not deepcompare.partial_compare((1, 2, 3, ), (2, 3, 1, )) - assert not deepcompare.partial_compare((1, 2, 3, ), (1, 2, 3, 4, )) + assert not deepcompare.partial_compare((1, 2, 3), (3, 2, 1)) + assert not deepcompare.partial_compare((1, 2, 3), (2, 3, 1)) + assert not deepcompare.partial_compare((1, 2, 3), (1, 2, 3, 4)) def test_compare_dict_with_dict(): # test full equality - assert deepcompare.partial_compare({'a': 1, 'b': 2, 'c': 3, }, {'a': 1, 'b': 2, 'c': 3, }) + assert deepcompare.partial_compare( + {"a": 1, "b": 2, "c": 3}, + {"a": 1, "b": 2, "c": 3}, + ) # test partial equality - assert deepcompare.partial_compare({'a': 1, 'b': 2, 'c': 3, }, {'a': 1, 'b': 2, }) + assert deepcompare.partial_compare({"a": 1, "b": 2, "c": 3}, {"a": 1, "b": 2}) # test non-equality - assert not deepcompare.partial_compare({'a': 1, 'b': 2, 'c': 3, }, {'a': 1, 'b': 2, 'c': 3, 'd': 4, }) + assert not deepcompare.partial_compare( + {"a": 1, "b": 2, "c": 3}, + {"a": 1, "b": 2, "c": 3, "d": 4}, + ) def test_compare_list_with_tuple_non_strict(): # test full equality - assert deepcompare.partial_compare([1, 2, 3, ], (1, 2, 3, )) + assert deepcompare.partial_compare([1, 2, 3], (1, 2, 3)) # test partial equality - assert deepcompare.partial_compare([1, 2, 3, ], (1,)) - assert deepcompare.partial_compare([1, 2, 3, ], (1, 2,)) - assert deepcompare.partial_compare([1, 2, 3, ], (1, 3,)) + assert deepcompare.partial_compare([1, 2, 3], (1,)) + assert deepcompare.partial_compare([1, 2, 3], (1, 2)) + assert deepcompare.partial_compare([1, 2, 3], (1, 3)) # test non-equality - assert not deepcompare.partial_compare([1, 2, 3, ], (3, 2, 1, )) - assert not deepcompare.partial_compare([1, 2, 3, ], (2, 3, 1, )) - assert not deepcompare.partial_compare([1, 2, 3, ], (1, 2, 3, 4, )) + assert not deepcompare.partial_compare([1, 2, 3], (3, 2, 1)) + assert not deepcompare.partial_compare([1, 2, 3], (2, 3, 1)) + assert not deepcompare.partial_compare([1, 2, 3], (1, 2, 3, 4)) def test_compare_list_with_tuple_strict(): # test full equality with type mismatch - assert not deepcompare.partial_compare([1, 2, 3, ], (1, 2, 3, ), strict=True) + assert not deepcompare.partial_compare([1, 2, 3], (1, 2, 3), strict=True) # test partial equality with type mismatch - assert not deepcompare.partial_compare([1, 2, 3, ], (1,), strict=True) - assert not deepcompare.partial_compare([1, 2, 3, ], (1, 2,), strict=True) - assert not deepcompare.partial_compare([1, 2, 3, ], (1, 3,), strict=True) + assert not deepcompare.partial_compare([1, 2, 3], (1,), strict=True) + assert not deepcompare.partial_compare([1, 2, 3], (1, 2), strict=True) + assert not deepcompare.partial_compare([1, 2, 3], (1, 3), strict=True) # test non-equality with type mismatch - assert not deepcompare.partial_compare([1, 2, 3, ], (3, 2, 1, ), strict=True) - assert not deepcompare.partial_compare([1, 2, 3, ], (2, 3, 1, ), strict=True) - assert not deepcompare.partial_compare([1, 2, 3, ], (1, 2, 3, 4, ), strict=True) + assert not deepcompare.partial_compare([1, 2, 3], (3, 2, 1), strict=True) + assert not deepcompare.partial_compare([1, 2, 3], (2, 3, 1), strict=True) + assert not deepcompare.partial_compare([1, 2, 3], (1, 2, 3, 4), strict=True) def test_compare_tuple_with_list_non_strict(): # test full equality - assert deepcompare.partial_compare((1, 2, 3, ), [1, 2, 3, ]) + assert deepcompare.partial_compare((1, 2, 3), [1, 2, 3]) # test partial equality - assert deepcompare.partial_compare((1, 2, 3,), [1, ]) - assert deepcompare.partial_compare((1, 2, 3,), [1, 2, ]) - assert deepcompare.partial_compare((1, 2, 3,), [1, 3, ]) + assert deepcompare.partial_compare((1, 2, 3), [1]) + assert deepcompare.partial_compare((1, 2, 3), [1, 2]) + assert deepcompare.partial_compare((1, 2, 3), [1, 3]) # test non-equality - assert not deepcompare.partial_compare((1, 2, 3, ), [3, 2, 1, ]) - assert not deepcompare.partial_compare((1, 2, 3, ), [2, 3, 1, ]) - assert not deepcompare.partial_compare((1, 2, 3, ), [1, 2, 3, 4, ]) + assert not deepcompare.partial_compare((1, 2, 3), [3, 2, 1]) + assert not deepcompare.partial_compare((1, 2, 3), [2, 3, 1]) + assert not deepcompare.partial_compare((1, 2, 3), [1, 2, 3, 4]) def test_compare_tuple_with_list_strict(): # test full equality with type mismatch - assert not deepcompare.partial_compare((1, 2, 3, ), [1, 2, 3, ], strict=True) + assert not deepcompare.partial_compare((1, 2, 3), [1, 2, 3], strict=True) # test partial equality with type mismatch - assert not deepcompare.partial_compare((1, 2, 3,), [1, ], strict=True) - assert not deepcompare.partial_compare((1, 2, 3,), [1, 2, ], strict=True) - assert not deepcompare.partial_compare((1, 2, 3,), [1, 3, ], strict=True) + assert not deepcompare.partial_compare((1, 2, 3), [1], strict=True) + assert not deepcompare.partial_compare((1, 2, 3), [1, 2], strict=True) + assert not deepcompare.partial_compare((1, 2, 3), [1, 3], strict=True) # test non-equality with type mismatch - assert not deepcompare.partial_compare((1, 2, 3, ), [3, 2, 1, ], strict=True) - assert not deepcompare.partial_compare((1, 2, 3, ), [2, 3, 1, ], strict=True) - assert not deepcompare.partial_compare((1, 2, 3, ), [1, 2, 3, 4, ], strict=True) + assert not deepcompare.partial_compare((1, 2, 3), [3, 2, 1], strict=True) + assert not deepcompare.partial_compare((1, 2, 3), [2, 3, 1], strict=True) + assert not deepcompare.partial_compare((1, 2, 3), [1, 2, 3, 4], strict=True) def test_compare_list_with_dict_non_strict(): # test non-equality - assert not deepcompare.partial_compare([1, 2, 3, ], {'a': 1, 'b': 2, 'c': 3, }) - assert not deepcompare.partial_compare([1, 2, 3, ], {'a': 1, 'b': 2, }) - assert not deepcompare.partial_compare([1, 2, 3, ], {'a': 1, 'b': 2, 'c': 3, 'd': 4, }) + assert not deepcompare.partial_compare([1, 2, 3], {"a": 1, "b": 2, "c": 3}) + assert not deepcompare.partial_compare([1, 2, 3], {"a": 1, "b": 2}) + assert not deepcompare.partial_compare([1, 2, 3], {"a": 1, "b": 2, "c": 3, "d": 4}) def test_compare_list_with_dict_strict(): # test non-equality with type mismatch - assert not deepcompare.partial_compare([1, 2, 3, ], {'a': 1, 'b': 2, 'c': 3, }, strict=True) - assert not deepcompare.partial_compare([1, 2, 3, ], {'a': 1, 'b': 2, }, strict=True) - assert not deepcompare.partial_compare([1, 2, 3, ], {'a': 1, 'b': 2, 'c': 3, 'd': 4, }, strict=True) + assert not deepcompare.partial_compare( + [1, 2, 3], + {"a": 1, "b": 2, "c": 3}, + strict=True, + ) + assert not deepcompare.partial_compare([1, 2, 3], {"a": 1, "b": 2}, strict=True) + assert not deepcompare.partial_compare( + [1, 2, 3], + {"a": 1, "b": 2, "c": 3, "d": 4}, + strict=True, + ) def test_compare_tuple_with_dict_non_strict(): # test non-equality - assert not deepcompare.partial_compare((1, 2, 3, ), {'a': 1, 'b': 2, 'c': 3, }) - assert not deepcompare.partial_compare((1, 2, 3, ), {'a': 1, 'b': 2, }) - assert not deepcompare.partial_compare((1, 2, 3, ), {'a': 1, 'b': 2, 'c': 3, 'd': 4, }) + assert not deepcompare.partial_compare((1, 2, 3), {"a": 1, "b": 2, "c": 3}) + assert not deepcompare.partial_compare((1, 2, 3), {"a": 1, "b": 2}) + assert not deepcompare.partial_compare((1, 2, 3), {"a": 1, "b": 2, "c": 3, "d": 4}) def test_compare_tuple_with_dict_strict(): # test non-equality with type mismatch - assert not deepcompare.partial_compare((1, 2, 3, ), {'a': 1, 'b': 2, 'c': 3, }, strict=True) - assert not deepcompare.partial_compare((1, 2, 3, ), {'a': 1, 'b': 2, }, strict=True) - assert not deepcompare.partial_compare((1, 2, 3, ), {'a': 1, 'b': 2, 'c': 3, 'd': 4, }, strict=True) + assert not deepcompare.partial_compare( + (1, 2, 3), + {"a": 1, "b": 2, "c": 3}, + strict=True, + ) + assert not deepcompare.partial_compare((1, 2, 3), {"a": 1, "b": 2}, strict=True) + assert not deepcompare.partial_compare( + (1, 2, 3), + {"a": 1, "b": 2, "c": 3, "d": 4}, + strict=True, + ) def test_compare_with_none_non_strict(): @@ -160,9 +182,9 @@ def test_compare_with_none_non_strict(): assert deepcompare.partial_compare(None, None) # test non-equality - assert not deepcompare.partial_compare(None, [1, 2, 3, ]) - assert not deepcompare.partial_compare(None, (1, 2, 3, )) - assert not deepcompare.partial_compare(None, {'a': 1, 'b': 2, 'c': 3, }) + assert not deepcompare.partial_compare(None, [1, 2, 3]) + assert not deepcompare.partial_compare(None, (1, 2, 3)) + assert not deepcompare.partial_compare(None, {"a": 1, "b": 2, "c": 3}) def test_compare_with_none_strict(): @@ -170,6 +192,6 @@ def test_compare_with_none_strict(): assert deepcompare.partial_compare(None, None, strict=True) # test non-equality - assert not deepcompare.partial_compare(None, [1, 2, 3, ], strict=True) - assert not deepcompare.partial_compare(None, (1, 2, 3, ), strict=True) - assert not deepcompare.partial_compare(None, {'a': 1, 'b': 2, 'c': 3, }, strict=True) + assert not deepcompare.partial_compare(None, [1, 2, 3], strict=True) + assert not deepcompare.partial_compare(None, (1, 2, 3), strict=True) + assert not deepcompare.partial_compare(None, {"a": 1, "b": 2, "c": 3}, strict=True)