Skip to content

Commit 472e54e

Browse files
authored
Fixed EncodingWarning when PYTHONWARNDEFAULTENCODING is set (#512)
1 parent 61e7eb8 commit 472e54e

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ jobs:
4848
run: pip install build flit
4949
- name: Test with pytest
5050
run: |
51-
coverage run -m pytest -W always
51+
coverage run -m pytest
5252
coverage xml
53+
env:
54+
PYTHONWARNDEFAULTENCODING: 1
5355
- name: Send coverage data to Codecov
5456
uses: codecov/codecov-action@v3
5557
with:

pyproject.toml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,15 @@ extend-exclude = '''
7474
'''
7575

7676
[tool.pytest.ini_options]
77-
testpaths = "tests"
77+
minversion = "6.0"
78+
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
79+
xfail_strict = true
80+
filterwarnings = [
81+
"error",
82+
"ignore::Warning:_pytest.*",
83+
]
84+
log_cli_level = "info"
85+
testpaths = ["test"]
7886

7987
[tool.coverage.run]
8088
source = ["wheel"]
@@ -112,8 +120,10 @@ skip_missing_interpreters = true
112120
113121
[testenv]
114122
depends = lint
115-
commands = {envpython} -b -m pytest -W always {posargs}
123+
commands = {envpython} -b -m pytest {posargs}
116124
extras = test
125+
set_env =
126+
PYTHONWARNDEFAULTENCODING = 1
117127
118128
[testenv:lint]
119129
depends =

src/wheel/bdist_wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def adios(p):
547547

548548
# delete dependency_links if it is only whitespace
549549
dependency_links_path = os.path.join(distinfo_path, "dependency_links.txt")
550-
with open(dependency_links_path) as dependency_links_file:
550+
with open(dependency_links_path, encoding="utf-8") as dependency_links_file:
551551
dependency_links = dependency_links_file.read().strip()
552552
if not dependency_links:
553553
adios(dependency_links_path)

src/wheel/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def pkginfo_to_metadata(egg_info_path: str, pkginfo_path: str) -> Message:
152152
del pkg_info["Requires-Dist"]
153153
requires_path = os.path.join(egg_info_path, "requires.txt")
154154
if os.path.exists(requires_path):
155-
with open(requires_path) as requires_file:
155+
with open(requires_path, encoding="utf-8") as requires_file:
156156
requires = requires_file.read()
157157

158158
parsed_requirements = sorted(split_sections(requires), key=lambda x: x[0] or "")

tests/cli/test_convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
def test_egg_re():
1111
"""Make sure egg_info_re matches."""
1212
egg_names_path = os.path.join(os.path.dirname(__file__), "eggnames.txt")
13-
with open(egg_names_path) as egg_names:
13+
with open(egg_names_path, encoding="utf-8") as egg_names:
1414
for line in egg_names:
1515
line = line.strip()
1616
if line:

0 commit comments

Comments
 (0)