File tree 3 files changed +23
-1
lines changed
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,18 @@ development at the same time, such as 4.5.x and 5.0.
20
20
Unreleased
21
21
----------
22
22
23
+ - Fix: if Python doesn't provide tomllib, then TOML configuration files can
24
+ only be read if coverage.py is installed with the ``[toml] `` extra.
25
+ Coverage.py will raise an error if toml support is not installed when it sees
26
+ your settings are in a .toml file. But it didn't understand that
27
+ ``[tools.coverage] `` was a valid section header, so the error wasn't
28
+ reported, and settings were silently ignored. This is now fixed, closing
29
+ `issue 1516 `_.
30
+
23
31
- Fix: adjusted how decorators are traced on PyPy 7.3.10, fixing `issue 1515 `_.
24
32
25
33
.. _issue 1515 : https://github.com/nedbat/coveragepy/issues/1515
34
+ .. _issue 1516 : https://github.com/nedbat/coveragepy/issues/1516
26
35
27
36
28
37
.. _changes_7-0-1 :
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ def read(self, filenames):
52
52
raise TomlDecodeError (str (err )) from err
53
53
return [filename ]
54
54
else :
55
- has_toml = re .search (r"^\[tool\.coverage\. " , toml_text , flags = re .MULTILINE )
55
+ has_toml = re .search (r"^\[tool\.coverage(\.|]) " , toml_text , flags = re .MULTILINE )
56
56
if self .our_file or has_toml :
57
57
# Looks like they meant to read TOML, but we can't read it.
58
58
msg = "Can't read {!r} without TOML support. Install with [toml] extra"
Original file line number Diff line number Diff line change @@ -739,6 +739,19 @@ def test_no_toml_installed_pyproject_toml(self):
739
739
with pytest .raises (ConfigError , match = msg ):
740
740
coverage .Coverage ()
741
741
742
+ @pytest .mark .skipif (sys .version_info >= (3 , 11 ), reason = "Python 3.11 has toml in stdlib" )
743
+ def test_no_toml_installed_pyproject_toml_shorter_syntax (self ):
744
+ # Can't have coverage config in pyproject.toml without toml installed.
745
+ self .make_file ("pyproject.toml" , """\
746
+ # A toml file!
747
+ [tool.coverage]
748
+ run.parallel = true
749
+ """ )
750
+ with without_module (coverage .tomlconfig , 'tomllib' ):
751
+ msg = "Can't read 'pyproject.toml' without TOML support"
752
+ with pytest .raises (ConfigError , match = msg ):
753
+ coverage .Coverage ()
754
+
742
755
def test_no_toml_installed_pyproject_no_coverage (self ):
743
756
# It's ok to have non-coverage pyproject.toml without toml installed.
744
757
self .make_file ("pyproject.toml" , """\
You can’t perform that action at this time.
0 commit comments