Skip to content

Commit

Permalink
Remove trailing whitespace; did not expect this would matter on a bla…
Browse files Browse the repository at this point in the history
…nk line.
  • Loading branch information
sdeibel committed Jan 30, 2023
1 parent 5ab1ac0 commit 85845ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions coverage/sqldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,29 +617,29 @@ def touch_files(self, filenames: Iterable[str], plugin_name: Optional[str] = Non

def purge_files(self, filenames, context=None):
"""Purge any existing coverage data for the given `filenames`.
If `context` is given, purge only data associated with that measurement context.
"""

if self._debug.should("dataop"):
self._debug.write(f"Purging {filenames!r} for context {context}")
self._start_using()
with self._connect() as con:

if context is not None:
context_id = self._context_id(context)
if context_id is None:
raise DataError("Unknown context {context}")
else:
context_id = None

if self._has_lines:
table = 'line_bits'
elif self._has_arcs:
table = 'arcs'
else:
return

for filename in filenames:
file_id = self._file_id(filename, add=False)
if file_id is None:
Expand Down
16 changes: 8 additions & 8 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ def test_run_debug_sys(self) -> None:
assert cast(str, d['data_file']).endswith(".coverage")

def test_purge_filenames(self) -> None:

fn1 = self.make_file("mymain.py", """\
import mymod
a = 1
Expand All @@ -771,7 +771,7 @@ def test_purge_filenames(self) -> None:
self.start_import_stop(cov, "mymain")

data = cov.get_data()

# Initial measurement was for two files
assert len(data.measured_files()) == 2
assert [1, 2] == sorted_lines(data, fn1)
Expand All @@ -788,9 +788,9 @@ def test_purge_filenames(self) -> None:
assert len(data.measured_files()) == 0
assert [] == sorted_lines(data, fn1)
assert [] == sorted_lines(data, fn2)

def test_purge_filenames_context(self) -> None:

fn1 = self.make_file("mymain.py", """\
import mymod
a = 1
Expand All @@ -804,7 +804,7 @@ def test_purge_filenames_context(self) -> None:

def dummy_function():
unused = 42

# Start/stop since otherwise cantext
cov = coverage.Coverage()
cov.start()
Expand All @@ -815,7 +815,7 @@ def dummy_function():
self.start_import_stop(cov, "mymain")

data = cov.get_data()

# Initial measurement was for three files and two contexts
assert len(data.measured_files()) == 3
assert [1, 2] == sorted_lines(data, fn1)
Expand Down Expand Up @@ -851,15 +851,15 @@ def dummy_function():
assert [1,] == sorted_lines(data, fn2)
assert len(sorted_lines(data, __file__)) == 0
assert len(data.measured_contexts()) == 2

# Remove last file specifying correct context
data.purge_files([fn2], 'testcontext')
assert len(data.measured_files()) == 0
assert [] == sorted_lines(data, fn1)
assert [] == sorted_lines(data, fn2)
assert len(sorted_lines(data, __file__)) == 0
assert len(data.measured_contexts()) == 2


class CurrentInstanceTest(CoverageTest):
"""Tests of Coverage.current()."""
Expand Down

0 comments on commit 85845ec

Please sign in to comment.