From ae9f040dc4189d73fdd708aa4ba61bf50d7b2a25 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 14 Oct 2018 20:39:46 -0400 Subject: Defer using the database when calling set_context #716 The collector calls set_context() before any code is run. If we touch the database there, it will get created *very* early. This causes problems with pytest-cov, which will delete those early-created files when erasing data. By deferring the database access until add_lines is called, the data file stays off the disk until the collection is done (or until the context switches), which avoids the problem. --- tests/test_debug.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_debug.py') diff --git a/tests/test_debug.py b/tests/test_debug.py index 63edc84f..284d9567 100644 --- a/tests/test_debug.py +++ b/tests/test_debug.py @@ -144,8 +144,8 @@ class DebugTraceTest(CoverageTest): self.assertRegex(real_messages[-1], r"^\s*\d+\.\w{4}: Writing data") self.assertRegex(last_line, r"\s+_write_file : .*coverage[/\\]data.py @\d+$") else: - self.assertRegex(real_messages[-1], r"^\s*\d+\.\w{4}: Adding lines") - self.assertRegex(last_line, r"\s+add_lines : .*coverage[/\\]sqldata.py @\d+$") + self.assertRegex(real_messages[-1], r"^\s*\d+\.\w{4}: Creating data file") + self.assertRegex(last_line, r"\s+_create_db : .*coverage[/\\]sqldata.py @\d+$") def test_debug_config(self): out_lines = self.f1_debug_output(["config"]) -- cgit v1.2.1