Skip to content

fix(test): EncodingWarning: 'encoding' argument not specified - #3228

Merged
gaborbernat merged 3 commits into
pypa:mainfrom
even-even:fix/warns_encoding_utf8
Sep 1, 2026
Merged

fix(test): EncodingWarning: 'encoding' argument not specified#3228
gaborbernat merged 3 commits into
pypa:mainfrom
even-even:fix/warns_encoding_utf8

Conversation

@even-even

Copy link
Copy Markdown
Contributor

Thanks for contributing, make sure you address all the checklists (for details on how see development documentation)

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

Hello

When running the tests, I see warnings.
`(virtualenv) ➜ virtualenv git:(main) tox -e py315
...
...
....................s............................................................................................ss...sss......................ss...... [ 41%]
s.....s....s....................s.....s...............s.s..s.......................................................................................s... [ 83%]
......................s............s........s............. [100%]
====================================================================== warnings summary =======================================================================
tests/unit/test_util.py::test_safe_delete_raises_the_original_error_not_a_retry_failure
/Users/vyuroshchin/github_my/virtualenv/tests/unit/test_util.py:64: EncodingWarning: 'encoding' argument not specified
(blocked / "wheel.py").write_text("cached")

tests/unit/test_util.py::test_safe_delete_keeps_the_other_mode_bits_when_clearing_read_only
/Users/vyuroshchin/github_my/virtualenv/tests/unit/test_util.py:79: EncodingWarning: 'encoding' argument not specified
blocked.write_text("cached")

tests/unit/seed/embed/test_bootstrap_link_via_app_data.py::test_safe_extract_zip_allows_normal_entry
/Users/vyuroshchin/github_my/virtualenv/tests/unit/seed/embed/test_bootstrap_link_via_app_data.py:272: EncodingWarning: 'encoding' argument not specified
assert (target / "pkg" / "inner.txt").read_text() == "payload"

tests/unit/test_util.py::test_safe_delete_removes_read_only_files
/Users/vyuroshchin/github_my/virtualenv/tests/unit/test_util.py:36: EncodingWarning: 'encoding' argument not specified
marked.write_text("cached")

tests/unit/test_util.py::TestCacheDirMigration::test_migrate_old_to_new
/Users/vyuroshchin/github_my/virtualenv/tests/unit/test_util.py:128: EncodingWarning: 'encoding' argument not specified
(tmp_path / "old-data" / "test.txt").write_text("hello")

tests/unit/test_util.py::TestCacheDirMigration::test_migrate_old_to_new
/Users/vyuroshchin/github_my/virtualenv/tests/unit/test_util.py:137: EncodingWarning: 'encoding' argument not specified
assert (tmp_path / "new-cache" / "test.txt").read_text() == "hello"

tests/unit/test_util.py::TestCacheDirMigration::test_symlink_app_data_survives_migration[False]
tests/unit/test_util.py::TestCacheDirMigration::test_symlink_app_data_survives_migration[True]
/Users/vyuroshchin/github_my/virtualenv/tests/unit/test_util.py:202: EncodingWarning: 'encoding' argument not specified
(wheel_img / "pip.dist-info" / "METADATA").write_text("Name: pip")

tests/unit/test_util.py::TestCacheDirMigration::test_no_migration_when_new_exists
/Users/vyuroshchin/github_my/virtualenv/tests/unit/test_util.py:155: EncodingWarning: 'encoding' argument not specified
(tmp_path / "old-data" / "old.txt").write_text("old")

tests/unit/activation/test_bash.py::test_bash_activate_relocation_resolves_virtual_env
/Users/vyuroshchin/github_my/virtualenv/tests/unit/activation/test_bash.py:96: EncodingWarning: 'encoding' argument not specified.
result = subprocess.run(

tests/unit/create/test_creator.py::test_pyenv_cfg_preserves_symlinks
/Users/vyuroshchin/github_my/virtualenv/tests/unit/create/test_creator.py:827: EncodingWarning: 'encoding' argument not specified
real_file.write_text("test")

tests/unit/create/test_creator.py::test_pyenv_cfg_preserves_symlinks
/Users/vyuroshchin/github_my/virtualenv/tests/unit/create/test_creator.py:842: EncodingWarning: 'encoding' argument not specified
written_content = cfg_path.read_text()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
-------------------------------------- generated xml file: /Users/vyuroshchin/github_my/virtualenv/.tox/junit.py315.xml ---------------------------------------
======================================================== 340 passed, 20 skipped, 12 warnings in 46.79s ========================================================
`

In PR I fixed this warnings like https://github.com/python-poetry/poetry/pull/8893/changes#diff-a1176a239bb3b9e9eb632f8f1090097a3630cea9f405da6b0506642e5343dd07R921 (add param encoding="utf-8" in tests)

@gaborbernat
gaborbernat enabled auto-merge (squash) September 1, 2026 15:59
@gaborbernat
gaborbernat merged commit 2ef85af into pypa:main Sep 1, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants