Skip to content

Commit

Permalink
Fixed EncodingWarning when PYTHONWARNDEFAULTENCODING is set (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii authored Mar 13, 2023
1 parent 61e7eb8 commit 472e54e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ jobs:
run: pip install build flit
- name: Test with pytest
run: |
coverage run -m pytest -W always
coverage run -m pytest
coverage xml
env:
PYTHONWARNDEFAULTENCODING: 1
- name: Send coverage data to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,15 @@ extend-exclude = '''
'''

[tool.pytest.ini_options]
testpaths = "tests"
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
filterwarnings = [
"error",
"ignore::Warning:_pytest.*",
]
log_cli_level = "info"
testpaths = ["test"]

[tool.coverage.run]
source = ["wheel"]
Expand Down Expand Up @@ -112,8 +120,10 @@ skip_missing_interpreters = true
[testenv]
depends = lint
commands = {envpython} -b -m pytest -W always {posargs}
commands = {envpython} -b -m pytest {posargs}
extras = test
set_env =
PYTHONWARNDEFAULTENCODING = 1
[testenv:lint]
depends =
Expand Down
2 changes: 1 addition & 1 deletion src/wheel/bdist_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def adios(p):

# delete dependency_links if it is only whitespace
dependency_links_path = os.path.join(distinfo_path, "dependency_links.txt")
with open(dependency_links_path) as dependency_links_file:
with open(dependency_links_path, encoding="utf-8") as dependency_links_file:
dependency_links = dependency_links_file.read().strip()
if not dependency_links:
adios(dependency_links_path)
Expand Down
2 changes: 1 addition & 1 deletion src/wheel/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def pkginfo_to_metadata(egg_info_path: str, pkginfo_path: str) -> Message:
del pkg_info["Requires-Dist"]
requires_path = os.path.join(egg_info_path, "requires.txt")
if os.path.exists(requires_path):
with open(requires_path) as requires_file:
with open(requires_path, encoding="utf-8") as requires_file:
requires = requires_file.read()

parsed_requirements = sorted(split_sections(requires), key=lambda x: x[0] or "")
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def test_egg_re():
"""Make sure egg_info_re matches."""
egg_names_path = os.path.join(os.path.dirname(__file__), "eggnames.txt")
with open(egg_names_path) as egg_names:
with open(egg_names_path, encoding="utf-8") as egg_names:
for line in egg_names:
line = line.strip()
if line:
Expand Down

0 comments on commit 472e54e

Please sign in to comment.