Wie man pytest ERROR while parsing the following warning configuration: ... behebt
Problem:
Sie möchten eine Warnung während eines Unit-Tests ignorieren mit Code wie
pytest_filterwarnings.py
@pytest.mark.filterwarnings("divide by zero encountered in log10")
def test_auto_suffix_1d(self):
# ...aber Sie sehen eine Fehlermeldung wie
pytest_error.txt
ERROR: while parsing the following warning configuration:
divide by zero encountered in log10
This error occurred:
invalid action: 'divide by zero encountered in log10'Lösung
Im Argument zu @pytest.mark.filterwarnings(...) haben Sie das ignore:-Präfix vergessen:
Anstatt
pytest_filterwarnings_fixed.py
@pytest.mark.filterwarnings("divide by zero encountered in log10")schreiben Sie
pytest_filterwarnings_ignore.py
@pytest.mark.filterwarnings("ignore: divide by zero encountered in log10")Sie könnten einen Fehler wie diesen sehen:
pytest_error_output.txt
INTERNALERROR> while parsing the following warning:
INTERNALERROR> configurationOft ist die Ursache eine ungültige pytest.ini- oder pyproject.toml-Konfiguration. Beispiel pytest.ini:
pytest.ini
[pytest]
addopts = -ra -q
python_files = tests.py test_*.py *_test.pyValidieren Sie Ihre Konfiguration und entfernen Sie ungültige Optionen, um den Fehler zu beheben.
Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow