File tree Expand file tree Collapse file tree 5 files changed +17
-2
lines changed Expand file tree Collapse file tree 5 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -41,13 +41,18 @@ Version 6.4 — 2022-05-22
4141- A new debug option ``debug=sqldata `` adds more detail to ``debug=sql ``,
4242 logging all the data being written to the database.
4343
44+ - Previously, running ``coverage report `` (or any of the reporting commands) in
45+ an empty directory would create a .coverage data file. Now they do not,
46+ fixing `issue 1328 `_.
47+
4448- On Python 3.11, the ``[toml] `` extra no longer installs tomli, instead using
4549 tomllib from the standard library. Thanks `Shantanu <pull 1359 _>`_.
4650
4751- In-memory CoverageData objects now properly update(), closing `issue 1323 `_.
4852
4953.. _issue 1310 : https://github.com/nedbat/coveragepy/issues/1310
5054.. _issue 1323 : https://github.com/nedbat/coveragepy/issues/1323
55+ .. _issue 1328 : https://github.com/nedbat/coveragepy/issues/1328
5156.. _issue 1351 : https://github.com/nedbat/coveragepy/issues/1351
5257.. _pull 1354 : https://github.com/nedbat/coveragepy/pull/1354
5358.. _pull 1359 : https://github.com/nedbat/coveragepy/pull/1359
Original file line number Diff line number Diff line change @@ -783,8 +783,9 @@ def erase(self, parallel=False):
783783
784784 def read (self ):
785785 """Start using an existing data file."""
786- with self ._connect (): # TODO: doesn't look right
787- self ._have_used = True
786+ if os .path .exists (self ._filename ):
787+ with self ._connect ():
788+ self ._have_used = True
788789
789790 def write (self ):
790791 """Ensure the data is written to the data file."""
Original file line number Diff line number Diff line change @@ -118,6 +118,13 @@ class CoverageDataTest(CoverageTest):
118118 def test_empty_data_is_false (self ):
119119 covdata = DebugCoverageData ()
120120 assert not covdata
121+ self .assert_doesnt_exist (".coverage" )
122+
123+ def test_empty_data_is_false_when_read (self ):
124+ covdata = DebugCoverageData ()
125+ covdata .read ()
126+ assert not covdata
127+ self .assert_doesnt_exist (".coverage" )
121128
122129 def test_line_data_is_true (self ):
123130 covdata = DebugCoverageData ()
Original file line number Diff line number Diff line change @@ -450,6 +450,7 @@ def test_report_skip_covered_no_data(self):
450450 cov .load ()
451451 with pytest .raises (NoDataError , match = "No data to report." ):
452452 self .get_report (cov , skip_covered = True )
453+ self .assert_doesnt_exist (".coverage" )
453454
454455 def test_report_skip_empty (self ):
455456 self .make_file ("main.py" , """
Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ def test_no_data(self):
139139 with pytest .raises (NoDataError , match = "No data to report." ):
140140 self .run_xml_report ()
141141 self .assert_doesnt_exist ("coverage.xml" )
142+ self .assert_doesnt_exist (".coverage" )
142143
143144 def test_no_source (self ):
144145 # Written while investigating a bug, might as well keep it.
You can’t perform that action at this time.
0 commit comments