Skip to content

Commit 8323394

Browse files
Jayman2000adrienverge
authored andcommitted
CI: Fail when open()’s default encoding is used
The previous few commits have removed all calls to open() that use its default encoding. That being said, it’s still possible that code added in the future will contain that same mistake. This commit makes it so that the CI test job will fail if that mistake is made again. Unfortunately, it doesn’t look like coverage.py allows you to specify -X options [1] or warning filters [2] when running your tests [3]. To work around this problem, I’m running all of the Python code, including coverage.py itself, with -X warn_default_encoding and -W error::EncodingWarning. As a result, the CI test job will also fail if coverage.py uses open()’s default encoding. Hopefully, coverage.py won’t do that. If it does, then we can always temporarily revert this commit. [1]: <https://docs.python.org/3.12/using/cmdline.html#cmdoption-X> [2]: <https://docs.python.org/3.12/using/cmdline.html#cmdoption-W> [3]: <https://coverage.readthedocs.io/en/7.4.0/cmd.html#execution-coverage-run>
1 parent 4d7be6d commit 8323394

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

.github/workflows/tests.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ jobs:
5757
- run: pip install .
5858
# https://github.com/AndreMiras/coveralls-python-action/issues/18
5959
- run: echo -e "[run]\nrelative_files = True" > .coveragerc
60-
- run: coverage run -m unittest discover
60+
- run: >-
61+
python
62+
-X warn_default_encoding
63+
-W error::EncodingWarning
64+
-m coverage
65+
run
66+
-m unittest
67+
discover
6168
- name: Coveralls
6269
uses: AndreMiras/coveralls-python-action@develop

0 commit comments

Comments
 (0)