Skip to content

Commit 6999a4e

Browse files
committed
test: suppress one more EncodingWarning #1966
Without this, I got: ``` tests/test_oddball.py::DoctestTest::test_doctest /usr/local/pyenv/pyenv/versions/3.10.17/lib/python3.10/pdb.py:160: EncodingWarning: 'encoding' argument not specified with open(os.path.expanduser('~/.pdbrc')) as rcFile: ```
1 parent 2f1da95 commit 6999a4e

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

CHANGES.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ upgrading your version of coverage.py.
2323
Unreleased
2424
----------
2525

26-
Nothing yet.
26+
- A number of EncodingWarnings were fixed that could appear if you've enabled
27+
PYTHONWARNDEFAULTENCODING, fixing `issue 1966`_. Thanks, `Henry Schreiner
28+
<pull 1967_>`_.
2729

30+
.. _issue 1966: https://github.com/nedbat/coveragepy/issues/1966
31+
.. _pull 1967: https://github.com/nedbat/coveragepy/pull/1967
2832

2933
.. start-releases
3034

CONTRIBUTORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Greg Rogers
9595
Guido van Rossum
9696
Guillaume Chazarain
9797
Guillaume Pujol
98+
Henry Schreiner
9899
Holger Krekel
99100
Hugo van Kemenade
100101
Ian Moore

tests/test_oddball.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os.path
99
import re
1010
import sys
11+
import warnings
1112

1213
from flaky import flaky
1314
import pytest
@@ -465,7 +466,11 @@ def return_arg_or_void(arg):
465466
doctest.testmod(sys.modules[__name__]) # we're not __main__ :(
466467
''')
467468
cov = coverage.Coverage()
468-
self.start_import_stop(cov, "the_doctest")
469+
with warnings.catch_warnings():
470+
# Doctest calls pdb which opens ~/.pdbrc without an encoding argument,
471+
# but we don't care. PYVERSIONS: this was needed for 3.10 only.
472+
warnings.filterwarnings("ignore", r".*'encoding' argument not specified.*")
473+
self.start_import_stop(cov, "the_doctest")
469474
data = cov.get_data()
470475
assert len(data.measured_files()) == 1
471476
lines = sorted_lines(data, data.measured_files().pop())

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ setenv =
3131
# We want to know about missing encoding arguments, but we need to silence
3232
# some warnings that aren't ours. We can't silence them in 3.9 because
3333
# EncodingWarning doesn't exist yet, and it's hard to suppress them in some
34-
# environments and not others. So by default, don't warn, and will enable
34+
# environments and not others. So by default, don't warn, and we'll enable
3535
# the warning in a handful of environments to catch the problems.
3636
PYTHONWARNDEFAULTENCODING=
3737
py3{10,11,12,13,14}: PYTHONWARNDEFAULTENCODING=1

0 commit comments

Comments
 (0)