From 7f97a8fbeb4fad2d84fc5d36223c2a2e7f58c14b Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 10 Mar 2023 16:42:40 -0500 Subject: [PATCH 1/4] tests: better warning checking Signed-off-by: Henry Schreiner --- .github/workflows/test.yml | 4 +++- pyproject.toml | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 790a0784..48ffd2b8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: diff --git a/pyproject.toml b/pyproject.toml index 13715634..94bedc14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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::EncodingWarning:_pytest.*", +] +log_cli_level = "info" +testpaths = ["test"] [tool.coverage.run] source = ["wheel"] @@ -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 = From f27cf4adb64c417c4486c5a8cad03d6d4b419f3e Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sat, 4 Feb 2023 13:07:26 +0900 Subject: [PATCH 2/4] Fix EncodingWarning --- src/wheel/bdist_wheel.py | 2 +- src/wheel/metadata.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wheel/bdist_wheel.py b/src/wheel/bdist_wheel.py index c059ddc2..28a9050b 100644 --- a/src/wheel/bdist_wheel.py +++ b/src/wheel/bdist_wheel.py @@ -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) diff --git a/src/wheel/metadata.py b/src/wheel/metadata.py index 61c0e4e3..b391c962 100644 --- a/src/wheel/metadata.py +++ b/src/wheel/metadata.py @@ -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 "") From de80240b890a825e8f94c880f2845240493d82b6 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 10 Mar 2023 17:01:47 -0500 Subject: [PATCH 3/4] fix: add two more missed encodings Signed-off-by: Henry Schreiner --- tests/cli/test_convert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cli/test_convert.py b/tests/cli/test_convert.py index 87ca6f6e..4f26b237 100644 --- a/tests/cli/test_convert.py +++ b/tests/cli/test_convert.py @@ -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: From c8c99a1a29afa38ba685c3330c86807d15948f06 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 10 Mar 2023 17:09:49 -0500 Subject: [PATCH 4/4] tests: older Python's don't have an EncodingWarning for pytest to ignore Signed-off-by: Henry Schreiner --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 94bedc14..599995ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,7 +79,7 @@ addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] xfail_strict = true filterwarnings = [ "error", - "ignore::EncodingWarning:_pytest.*", + "ignore::Warning:_pytest.*", ] log_cli_level = "info" testpaths = ["test"]