Skip to content

Commit acd2a0b

Browse files
committed
Restricting EncodingWarning ignores in pytest.ini
1 parent b96c050 commit acd2a0b

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

pytest.ini

+22-20
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,6 @@ filterwarnings=
99
# Fail on warnings
1010
error
1111

12-
## upstream
13-
14-
# Ensure ResourceWarnings are emitted
15-
default::ResourceWarning
16-
17-
# realpython/pytest-mypy#152
18-
ignore:'encoding' argument not specified::pytest_mypy
19-
20-
# python/cpython#100750
21-
ignore:'encoding' argument not specified::platform
22-
23-
# pypa/build#615
24-
ignore:'encoding' argument not specified::build.env
25-
26-
# dateutil/dateutil#1284
27-
ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning:dateutil.tz.tz
28-
29-
## end upstream
30-
3112
# https://github.com/pypa/setuptools/issues/1823
3213
ignore:bdist_wininst command is deprecated
3314
# Suppress this error; unimportant for CI tests
@@ -71,7 +52,6 @@ filterwarnings=
7152
# Workarounds for pypa/setuptools#3810
7253
# Can't use EncodingWarning as it doesn't exist on Python 3.9
7354
default:'encoding' argument not specified
74-
default:UTF-8 Mode affects locale.getpreferredencoding().
7555

7656
# Avoid errors when testing pkg_resources.declare_namespace
7757
ignore:.*pkg_resources\.declare_namespace.*:DeprecationWarning
@@ -84,3 +64,25 @@ filterwarnings=
8464

8565
# Ignore warnings about experimental features
8666
ignore:..tool\.distutils.. in .pyproject\.toml. is still .experimental.*
67+
68+
## upstream
69+
70+
# Ensure ResourceWarnings are emitted
71+
default::ResourceWarning
72+
73+
# realpython/pytest-mypy#152
74+
ignore:'encoding' argument not specified::pytest_mypy
75+
76+
77+
# pypa/pip#12070
78+
ignore:'encoding' argument not specified::pip
79+
80+
# TODO: These 2 ignores don't work, why?
81+
82+
# pytest-dev/pytest # TODO: Raise issue upstream
83+
ignore:'encoding' argument not specified::_pytest
84+
85+
# pypa/distutils # TODO: Raise issue upstream
86+
ignore:'encoding' argument not specified::setuptools._distutils
87+
88+
## end upstream

setuptools/tests/__init__.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import locale
2+
import sys
23

34
import pytest
45

56

67
__all__ = ['fail_on_ascii']
78

89

9-
is_ascii = locale.getpreferredencoding() == 'ANSI_X3.4-1968'
10+
encoding = (
11+
locale.getencoding()
12+
if sys.version_info >= (3, 11)
13+
else locale.getpreferredencoding()
14+
)
15+
is_ascii = encoding == 'ANSI_X3.4-1968'
1016
fail_on_ascii = pytest.mark.xfail(is_ascii, reason="Test fails in this locale")

setuptools/tests/environment.py

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ def run(self, cmd, *args, **kwargs):
3131
if "PYTHONPATH" in env:
3232
del env["PYTHONPATH"]
3333
kwargs["env"] = env
34-
# Don't stringify the output, but also avoid EncodingWarning about missing encoding
35-
kwargs.setdefault("encoding", None)
3634
return subprocess.check_output(cmd, *args, **kwargs)
3735

3836

0 commit comments

Comments
 (0)