Skip to content

Commit

Permalink
Fix #16
Browse files Browse the repository at this point in the history
  • Loading branch information
utapyngo committed Jul 5, 2024
1 parent 1b8a29f commit ce326e9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
with:
python-version: "${{ matrix.python-version }}"
- name: Install dependencies
run: python -m pip install tox "${{ matrix.pytest-version }}" pytest-cov .
run: python -m pip install mock tox "${{ matrix.pytest-version }}" pytest-cov .
- name: Test
run: |
coverage run --branch --source=pytest_unordered -m pytest tests/
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog


## [0.6.1] - 2024-07-05
- Fix matching with `mock.ANY` (#16)


## [0.6.0] - 2024-03-13
- Add Pytest 8 support
- Add Python 3.12 support
Expand Down
6 changes: 4 additions & 2 deletions pytest_unordered/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ def compare_to(self, other: List) -> Tuple[List, List]:
placeholder = object()
for elem in other:
try:
extra_left.remove(elem)
reordered.append(elem)
i = extra_left.index(elem)
matched_element = extra_left[i]
del extra_left[i]
reordered.append(matched_element)
except ValueError:
extra_right.append(elem)
reordered.append(placeholder)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def read(fname: str) -> str:

setup(
name="pytest-unordered",
version="0.6.0",
version="0.6.1",
author="Ivan Zaikin",
author_email="ut@pyngo.tom.ru",
maintainer="Ivan Zaikin",
Expand Down
11 changes: 11 additions & 0 deletions tests/test_unordered.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from _pytest.pytester import Pytester
from pytest import raises

from mock import ANY
from pytest_unordered import UnorderedList
from pytest_unordered import _compare_eq_unordered
from pytest_unordered import unordered
Expand Down Expand Up @@ -244,3 +245,13 @@ def test_reorder_on_eq() -> None:
unordered_list = unordered([1, 2, 3])
assert unordered_list == [3, 1, 2]
assert list(unordered_list) == [3, 1, 2]


def test_mock_any() -> None:
p_unordered = {"results": unordered({"foo1": ANY}, {"foo2": ANY})}
test_1 = {"results": [{"foo1": "value10"}, {"foo2": "value20"}]}
test_2 = {"results": [{"foo1": "value11"}, {"foo2": "value21"}]}
test_3 = {"results": [{"foo1": "value10"}, {"foo2": "value20"}]}
assert p_unordered == test_1
assert p_unordered == test_2
assert p_unordered == test_3
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ commands =
deps =
coverage
codecov
mock
pytest7: pytest==7.4.4
pytest8: pytest==8.1.1
pytestlatest: pytest
Expand Down

0 comments on commit ce326e9

Please # to comment.