Skip to content

How to use side_effect from pytest framework with pydantic.ValidationError class? #6459

Answered by nekeal
leonartdoss asked this question in Question
Discussion options

You must be logged in to vote

You could use ValidationError.from_exception_data() method.

from unittest.mock import Mock
from pydantic import ValidationError
func = Mock()
func.side_effect = ValidationError.from_exception_data("Invalid data", line_errors=[])
func()

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mzamini92
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@vcidst
Comment options

@bmchilds
Comment options

@evan-hitobito
Comment options

Answer selected by Viicos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants