@@ -202,8 +202,8 @@ Compare tuples, sets or models in a single assert, so that a failure shows all t
202202
203203``` python
204204assert (note.title, note.description, note.category) == (data.title, data.description, category)
205- assert {note.id for note in notes} == created # order does not matter
206- assert ApiResponse[Note].model_validate(response.json()).data == note # pydantic models compare by value
205+ assert {note.id for note in notes} == created # order does not matter
206+ assert ApiResponse[Note].model_validate(response.json()).data == note # pydantic models compare by value
207207```
208208
209209** In the framework:**
@@ -283,7 +283,7 @@ then decides how many items it needs, and the fixture cleans up all of them:
283283@pytest.fixture
284284def unregistered_cleanup (settings ):
285285 created = []
286- yield created # the test appends (email, password)
286+ yield created # the test appends (email, password)
287287 for email, password in created:
288288 _delete_account(settings, email, password)
289289```
@@ -461,7 +461,7 @@ may still be updating. Use `expect` for anything shown in the page.
461461
462462``` python
463463expect(notes_page.progress).to_have_text(" You have completed all notes" )
464- expect(notes_page.card_titles).to_have_text([notes[" Work" ].title]) # the exact list of elements
464+ expect(notes_page.card_titles).to_have_text([notes[" Work" ].title]) # the exact list of elements
465465```
466466
467467** In the framework:** UI tests assert with ` expect ` ; plain ` assert ` is used only for API values.
@@ -619,7 +619,7 @@ A contract test checks that the response has the agreed shape: every field prese
619619types and allowed values, and no surprise fields. In pydantic you describe the shape once as a model:
620620
621621``` python
622- class Note (Contract ): # Contract sets extra="forbid"
622+ class Note (Contract ): # Contract sets extra="forbid"
623623 id : str
624624 category: Literal[" Home" , " Work" , " Personal" ]
625625 completed: bool
@@ -649,9 +649,10 @@ class ApiResponse(Contract, Generic[T]):
649649 message: str
650650 data: T | None = None
651651
652- ApiResponse[Note] # one note
653- ApiResponse[list[Note]] # a list
654- ApiResponse[User] # a user
652+
653+ ApiResponse[Note] # one note
654+ ApiResponse[list[Note]] # a list
655+ ApiResponse[User] # a user
655656```
656657
657658### Q50. pydantic or JSON Schema (jsonschema library)?
0 commit comments