Skip to content

Commit 2cee76e

Browse files
committed
Read the config file contents as bytes, it's just for debugging anyway. #990
1 parent a462ab4 commit 2cee76e

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ Unreleased
2828
``--precision`` option to control the number of decimal points displayed.
2929
Thanks, Teake Nutma.
3030

31+
- TOML configuration files with non-ASCII characters would cause errors on
32+
Windows (`issue 990`_). This is now fixed.
33+
34+
.. _issue 990: https://github.com/nedbat/coveragepy/issues/990
35+
3136

3237
.. _changes_51:
3338

coverage/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def from_file(self, filename, our_file):
325325

326326
if used:
327327
self.config_file = os.path.abspath(filename)
328-
with open(filename) as f:
328+
with open(filename, "rb") as f:
329329
self._config_contents = f.read()
330330

331331
return used

tests/test_config.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
44

55
"""Test the config file handling for coverage.py"""
6+
67
from collections import OrderedDict
78

89
import mock
@@ -62,6 +63,8 @@ def test_toml_config_file(self):
6263
# A .coveragerc file will be read into the configuration.
6364
self.make_file("pyproject.toml", """\
6465
# This is just a bogus toml file for testing.
66+
[tool.somethingelse]
67+
authors = ["Joe D'Ávila <[email protected]>"]
6568
[tool.coverage.run]
6669
concurrency = ["a", "b"]
6770
timid = true
@@ -70,20 +73,23 @@ def test_toml_config_file(self):
7073
[tool.coverage.report]
7174
precision = 3
7275
fail_under = 90.5
76+
[tool.coverage.html]
77+
title = "tabblo & «ταБЬℓσ»"
7378
[tool.coverage.plugins.a_plugin]
7479
hello = "world"
7580
""")
7681
cov = coverage.Coverage(config_file="pyproject.toml")
7782
self.assertTrue(cov.config.timid)
7883
self.assertFalse(cov.config.branch)
79-
self.assertEqual(cov.config.concurrency, ["a", "b"])
80-
self.assertEqual(cov.config.data_file, ".hello_kitty.data")
81-
self.assertEqual(cov.config.plugins, ["plugins.a_plugin"])
84+
self.assertEqual(cov.config.concurrency, [u"a", u"b"])
85+
self.assertEqual(cov.config.data_file, u".hello_kitty.data")
86+
self.assertEqual(cov.config.plugins, [u"plugins.a_plugin"])
8287
self.assertEqual(cov.config.precision, 3)
88+
self.assertEqual(cov.config.html_title, u"tabblo & «ταБЬℓσ»")
8389
self.assertAlmostEqual(cov.config.fail_under, 90.5)
8490
self.assertEqual(
8591
cov.config.get_plugin_options("plugins.a_plugin"),
86-
{'hello': 'world'}
92+
{u"hello": u"world"}
8793
)
8894

8995
# Test that our class doesn't reject integers when loading floats

0 commit comments

Comments
 (0)