Skip to content

Commit b03930b

Browse files
Updated the people_test.py file.
Added some detail in comments about soft_assertion in assertpy module.
1 parent 2ca9964 commit b03930b

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ pytest = "*"
1111
assertpy = "*"
1212

1313
[requires]
14-
python_version = "3.8"
14+
python_version = "3.9"

tests/people_test.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,27 @@
22
from uuid import uuid4
33

44
import requests
5-
from assertpy.assertpy import assert_that
5+
from assertpy.assertpy import assert_that, soft_assertions
66

77
from config import BASE_URI
88

99

1010
def test_read_all_has_kent():
1111
# We use requests.get() with url to make a get request
1212
response = requests.get(BASE_URI)
13-
# response from requests has many useful properties
14-
# we can assert on the response status code
15-
assert_that(response.status_code).is_equal_to(requests.codes.ok)
16-
# We can get python dict as response by using .json() method
17-
response_content = response.json()
18-
19-
# Use assertpy's fluent assertions to extract all fnames and then see the result is non empty and has
20-
# Kent in it.
21-
assert_that(response_content).extracting('fname').is_not_empty().contains('Kent')
13+
# Added the soft_assertions() - we use this when we want our Test to run successfully (means failing one test won't
14+
# stop the Test script's execution). Collect all the failures, consolidate all the errors and return all the test
15+
# failures in last.
16+
with soft_assertions():
17+
# response from requests has many useful properties
18+
# we can assert on the response status code
19+
assert_that(response.status_code).is_equal_to(requests.codes.ok)
20+
# We can get python dict as response by using .json() method
21+
response_content = response.json()
22+
23+
# Use assertpy's fluent assertions to extract all fnames and then see the result is non empty and has
24+
# Kent in it.
25+
assert_that(response_content).extracting('fname').is_not_empty().contains('Kent')
2226

2327

2428
def test_new_person_can_be_added():

0 commit comments

Comments
 (0)