-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathall_of_tests.py
More file actions
35 lines (22 loc) · 1.05 KB
/
all_of_tests.py
File metadata and controls
35 lines (22 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import collections
from precisely import all_of, has_attr, equal_to
from precisely.results import matched, unmatched
User = collections.namedtuple("User", ["username", "email_address"])
def test_matches_when_submatchers_all_match():
matcher = all_of(
has_attr("username", equal_to("bob")),
has_attr("email_address", equal_to("bob@example.com")),
)
assert matched() == matcher.match(User("bob", "bob@example.com"))
def test_mismatches_when_submatcher_mismatches():
matcher = all_of(
has_attr("username", equal_to("bob")),
has_attr("email_address", equal_to("bob@example.com")),
)
assert unmatched("was missing attribute username") == matcher.match("bobbity")
def test_description_contains_descriptions_of_submatchers():
matcher = all_of(
has_attr("username", equal_to("bob")),
has_attr("email_address", equal_to("bob@example.com")),
)
assert "all of:\n * object with attribute username: 'bob'\n * object with attribute email_address: 'bob@example.com'" == matcher.describe()