Commit daf7820f authored by Kirill Smelkov's avatar Kirill Smelkov

promis/plugin/check_free_disk_space: test: Fix unclosed file ResourceWarning

folder_disk_test.sql was opened to be read but was not closed:

    slapos.toolbox$ python -m unittest discover -v   -s slapos/test/promise/plugin/ -t . -k test_display_prediction
    test_display_prediction (slapos.test.promise.plugin.test_check_free_disk_space.testcheckfreediskspace.test_display_prediction) ...
    /usr/lib/python3.11/unittest/case.py:576: resourcewarning: unclosed file <_io.textiowrapper name='/home/kirr/src/wendelin/slapos/slapos.toolbox/slapos/test/promise/data/disktest.sql' mode='r' encoding='utf-8'>
      self.setup()

/cc @Just1, @lu.xu, @jhuge, @tomo
/reviewed-on !124
parent dfb32247
...@@ -57,8 +57,8 @@ class TestMonitorPartitionSpace(TestPromisePluginMixin): ...@@ -57,8 +57,8 @@ class TestMonitorPartitionSpace(TestPromisePluginMixin):
# populate db # populate db
self.conn = sqlite3.connect(self.db_file) self.conn = sqlite3.connect(self.db_file)
f = open(self.base_path+"/folder_disk_test.sql") with open(self.base_path+"/folder_disk_test.sql") as f:
sql = f.read() sql = f.read()
# replace every disk_partition_name string with disk partition name # replace every disk_partition_name string with disk partition name
sql = sql.replace('disk_partition_name', disk_partition) sql = sql.replace('disk_partition_name', disk_partition)
self.conn.executescript(sql) self.conn.executescript(sql)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment