How to fix pytest ERROR while parsing the following warning configuration: ...

Problem:

You want to ignore a warning during a unit test using code such as

@pytest.mark.filterwarnings("divide by zero encountered in log10")
def test_auto_suffix_1d(self):
   # ...

but you see an error message such as

ERROR: while parsing the following warning configuration:

  divide by zero encountered in log10

This error occurred:

invalid action: 'divide by zero encountered in log10'

Solution:

In the argument to @pytest.mark.filterwarnings(...) you forgot the ignore: prefix:

Instead of

@pytest.mark.filterwarnings("divide by zero encountered in log10")

write

@pytest.mark.filterwarnings("ignore: divide by zero encountered in log10")