From 9e645c4d442fa8f252983d8a68b1334918374d29 Mon Sep 17 00:00:00 2001 From: Anthony Shaw Date: Tue, 13 Feb 2024 16:01:46 +1100 Subject: [PATCH] Mute deprecation warning of getdefaultlocale until a better solution is found --- pytest_nunit/nunit.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pytest_nunit/nunit.py b/pytest_nunit/nunit.py index 3488cf2..2f19e58 100644 --- a/pytest_nunit/nunit.py +++ b/pytest_nunit/nunit.py @@ -3,6 +3,7 @@ import os import platform import sys +import warnings from _pytest._code.code import ExceptionChainRepr @@ -116,7 +117,11 @@ def _format_filters(filters_): def _getlocale(): - language_code = locale.getdefaultlocale()[0] + # See https://github.com/pytest-dev/pytest-nunit/pull/73 + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + language_code = locale.getdefaultlocale()[0] + if language_code: return language_code return "en-US"