summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcrvi <crvisqr@gmail.com>2020-08-14 03:03:27 +0530
committercrvi <crvisqr@gmail.com>2020-08-14 03:44:02 +0530
commite68d4b07a74434dbed3fb92779891e2f325b00eb (patch)
tree14db615c5c01222b63a1dbcf6e3e11499c03b9e4 /test
parentec864ad39bc7a4ed46d2396871f89363dc209c5f (diff)
downloadzeitgeist-e68d4b07a74434dbed3fb92779891e2f325b00eb.tar.gz
test: fix ResourceWarning: unclosed file errors
Diffstat (limited to 'test')
-rw-r--r--test/dbus/testutils.py3
-rw-r--r--test/dbus/upgrade-test.py3
2 files changed, 4 insertions, 2 deletions
diff --git a/test/dbus/testutils.py b/test/dbus/testutils.py
index ad2fe25c..cffcc683 100644
--- a/test/dbus/testutils.py
+++ b/test/dbus/testutils.py
@@ -77,7 +77,8 @@ def dict2event(d):
return ev
def parse_events(path):
- data = json.load(open(path))
+ with open(path) as f:
+ data = json.load(f)
events = list(map(dict2event, data))
return events
diff --git a/test/dbus/upgrade-test.py b/test/dbus/upgrade-test.py
index 6e9a7b3c..2854cf3b 100644
--- a/test/dbus/upgrade-test.py
+++ b/test/dbus/upgrade-test.py
@@ -42,7 +42,8 @@ class ZeitgeistUpgradeTest(testutils.RemoteTestCase):
def prepare(self, from_version):
# Create initial database
con = sqlite3.connect(self._db_file)
- initial_sql = open("test/data/databases/%s.sql" % from_version).read()
+ with open("test/data/databases/%s.sql" % from_version) as f:
+ initial_sql = f.read()
con.cursor().executescript(initial_sql)
del con