File tree 5 files changed +17
-2
lines changed
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
41
41
- A new debug option ``debug=sqldata `` adds more detail to ``debug=sql ``,
42
42
logging all the data being written to the database.
43
43
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
+
44
48
- On Python 3.11, the ``[toml] `` extra no longer installs tomli, instead using
45
49
tomllib from the standard library. Thanks `Shantanu <pull 1359 _>`_.
46
50
47
51
- In-memory CoverageData objects now properly update(), closing `issue 1323 `_.
48
52
49
53
.. _issue 1310 : https://github.com/nedbat/coveragepy/issues/1310
50
54
.. _issue 1323 : https://github.com/nedbat/coveragepy/issues/1323
55
+ .. _issue 1328 : https://github.com/nedbat/coveragepy/issues/1328
51
56
.. _issue 1351 : https://github.com/nedbat/coveragepy/issues/1351
52
57
.. _pull 1354 : https://github.com/nedbat/coveragepy/pull/1354
53
58
.. _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):
783
783
784
784
def read (self ):
785
785
"""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
788
789
789
790
def write (self ):
790
791
"""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):
118
118
def test_empty_data_is_false (self ):
119
119
covdata = DebugCoverageData ()
120
120
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" )
121
128
122
129
def test_line_data_is_true (self ):
123
130
covdata = DebugCoverageData ()
Original file line number Diff line number Diff line change @@ -450,6 +450,7 @@ def test_report_skip_covered_no_data(self):
450
450
cov .load ()
451
451
with pytest .raises (NoDataError , match = "No data to report." ):
452
452
self .get_report (cov , skip_covered = True )
453
+ self .assert_doesnt_exist (".coverage" )
453
454
454
455
def test_report_skip_empty (self ):
455
456
self .make_file ("main.py" , """
Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ def test_no_data(self):
139
139
with pytest .raises (NoDataError , match = "No data to report." ):
140
140
self .run_xml_report ()
141
141
self .assert_doesnt_exist ("coverage.xml" )
142
+ self .assert_doesnt_exist (".coverage" )
142
143
143
144
def test_no_source (self ):
144
145
# Written while investigating a bug, might as well keep it.
You can’t perform that action at this time.
0 commit comments