Ask Your Question
2

What is the method to cause pytest to generate an error upon encountering a warning?

asked 2023-07-03 16:19:00 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-07-03 16:43:02 +0000

ladyg gravatar image

You can cause pytest to generate an error upon encountering a warning by using the --strict command-line option or adding strict = True to your pytest.ini file. This option causes pytest to fail any test that generates a warning.

For example, you can run pytest with the --strict option like this:

pytest --strict

Or you can add strict = True to your pytest.ini file:

[pytest]
strict = True

This method ensures that any test that produces a warning also fails, helping you identify potential issues in your code.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-03 16:19:00 +0000

Seen: 11 times

Last updated: Jul 03 '23