Modernize the skipped `test_issue_9765` regression test (#12468)

* 🚑 Explicitly set encoding @ `subprocess.run()`

This invocation is present in the `test_issue_9765` regression test
that is always skipped unconditionally, resulting in the
`EncodingWarning` never manifesting itself in CI or development
environments of the contributors.

* Change `setup.py` call w/ `pip install` @ tests

Using this CLI interface has been deprecated in `setuptools` [[1]].

[1]: https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html
This commit is contained in:
Sviatoslav Sydorenko (Святослав Сидоренко) 2024-06-17 17:44:14 +02:00 committed by GitHub
parent 80b7657b2a
commit fe4961afae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 2 deletions

View File

@ -1464,14 +1464,21 @@ def test_issue_9765(pytester: Pytester) -> None:
}
)
subprocess.run([sys.executable, "setup.py", "develop"], check=True)
subprocess.run(
[sys.executable, "-Im", "pip", "install", "-e", "."],
check=True,
)
try:
# We are using subprocess.run rather than pytester.run on purpose.
# pytester.run is adding the current directory to PYTHONPATH which avoids
# the bug. We also use pytest rather than python -m pytest for the same
# PYTHONPATH reason.
subprocess.run(
["pytest", "my_package"], capture_output=True, check=True, text=True
["pytest", "my_package"],
capture_output=True,
check=True,
encoding="utf-8",
text=True,
)
except subprocess.CalledProcessError as exc:
raise AssertionError(