File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1032,7 +1032,11 @@ def _connect(self):
1032
1032
# is not a problem.
1033
1033
if self .debug :
1034
1034
self .debug .write (f"Connecting to { self .filename !r} " )
1035
- self .con = sqlite3 .connect (self .filename , check_same_thread = False )
1035
+ try :
1036
+ self .con = sqlite3 .connect (self .filename , check_same_thread = False )
1037
+ except sqlite3 .Error as exc :
1038
+ raise CoverageException (f"Couldn't use data file { self .filename !r} : { exc } " ) from exc
1039
+
1036
1040
self .con .create_function ("REGEXP" , 2 , _regexp )
1037
1041
1038
1042
# This pragma makes writing faster. It disables rollbacks, but we never need them.
Original file line number Diff line number Diff line change @@ -598,6 +598,14 @@ def test_read_errors(self):
598
598
covdata .read ()
599
599
assert not covdata
600
600
601
+ def test_hard_read_error (self ):
602
+ self .make_file ("noperms.dat" , "go away" )
603
+ os .chmod ("noperms.dat" , 0 )
604
+ msg = r"Couldn't .* '.*[/\\]{}': \S+"
605
+ with pytest .raises (CoverageException , match = msg .format ("noperms.dat" )):
606
+ covdata = DebugCoverageData ("noperms.dat" )
607
+ covdata .read ()
608
+
601
609
def test_read_sql_errors (self ):
602
610
with sqlite3 .connect ("wrong_schema.db" ) as con :
603
611
con .execute ("create table coverage_schema (version integer)" )
You can’t perform that action at this time.
0 commit comments