Skip to content

Commit 44401b2

Browse files
authored
Merge pull request #19 from jacebrowning/simplify-diffs
Simplify diffs using 'expect.anything'
2 parents bb92389 + 306c7a5 commit 44401b2

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.3 (2022-01-20)
2+
3+
- Updated the representation of `expect.anything` to simplify diffs.
4+
15
# 2.2 (2020-07-08)
26

37
- Added support for matching non-identity via `expect(actual).is_not(expected)`.

docs/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
mkdocs==1.2.3; python_version >= "3.6"
22
pygments==2.11.2; python_version >= "3.5"
3+
mkdocs==1.2.3; python_version >= "3.6"
4+
pygments==2.11.2; python_version >= "3.5"

expecter/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
class Anything:
2828
"""Placeholder value to ignore uninteresting response data."""
2929

30+
def __repr__(self):
31+
return '<anything>'
32+
3033
def __eq__(self, other):
3134
return True
3235

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22

33
name = "pytest-expecter"
4-
version = "2.2"
4+
version = "2.3"
55
description = "Better testing with expecter and pytest."
66

77
license = "BSD"

tests/test_diff.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,11 @@ def _fails():
6767
"-[{'a': 1, 'b': 22, 'c': 3, 'd': 4, 'f': 6, 'g': 7}]\n"
6868
"+[{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6}]"
6969
), fail_msg(_fails)
70+
71+
def it_supports_ignoring_values_with_anything():
72+
def _fails():
73+
expect({'foo': 2, 'bar': None}) == {'foo': 1, 'bar': expect.anything}
74+
75+
with pytest.raises(AssertionError):
76+
_fails()
77+
assert "'bar': <anything>" in fail_msg(_fails), fail_msg(_fails)

0 commit comments

Comments
 (0)