Fix miscellaneous warnings
Among them: - explicitly close files (possibly using with: syntax) - use non-deprecated methods
This commit is contained in:
parent
b212a75ba3
commit
df03800278
@ -675,7 +675,7 @@ class SystemTestsMixin(object):
|
||||
try:
|
||||
# XXX .is_running() may throw libvirtError if undefined
|
||||
if vm.is_running():
|
||||
vm.force_shutdown()
|
||||
vm.kill()
|
||||
except: # pylint: disable=bare-except
|
||||
pass
|
||||
|
||||
|
@ -79,7 +79,7 @@ class TC_10_property(qubes.tests.QubesTestCase):
|
||||
hash(self.holder.__class__.testprop1)
|
||||
|
||||
def test_002_eq(self):
|
||||
self.assertEquals(qubes.property('testprop2'),
|
||||
self.assertEqual(qubes.property('testprop2'),
|
||||
qubes.property('testprop2'))
|
||||
|
||||
def test_010_set(self):
|
||||
@ -116,7 +116,7 @@ class TC_10_property(qubes.tests.QubesTestCase):
|
||||
def setter(self2, prop, value):
|
||||
self.assertIs(self2, holder)
|
||||
self.assertIs(prop, MyTestHolder.testprop1)
|
||||
self.assertEquals(value, 'testvalue')
|
||||
self.assertEqual(value, 'testvalue')
|
||||
return 'settervalue'
|
||||
|
||||
class MyTestHolder(qubes.tests.TestEmitter, qubes.PropertyHolder):
|
||||
@ -236,9 +236,9 @@ class TC_20_PropertyHolder(qubes.tests.QubesTestCase):
|
||||
self.assertEventFired(self.holder, 'property-loaded')
|
||||
self.assertEventNotFired(self.holder, 'property-set:testprop1')
|
||||
|
||||
self.assertEquals(self.holder.testprop1, 'testvalue1')
|
||||
self.assertEquals(self.holder.testprop2, 'testref2')
|
||||
self.assertEquals(self.holder.testprop3, 'testdefault')
|
||||
self.assertEqual(self.holder.testprop1, 'testvalue1')
|
||||
self.assertEqual(self.holder.testprop2, 'testref2')
|
||||
self.assertEqual(self.holder.testprop3, 'testdefault')
|
||||
|
||||
with self.assertRaises(AttributeError):
|
||||
self.holder.testprop4
|
||||
|
@ -257,7 +257,7 @@ class BackupTestsMixin(qubes.tests.SystemTestsMixin):
|
||||
'internal'):
|
||||
if not hasattr(vm, prop):
|
||||
continue
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
getattr(vm, prop), getattr(restored_vm, prop),
|
||||
"VM {} - property {} not properly restored".format(
|
||||
vm.name, prop))
|
||||
@ -267,11 +267,11 @@ class BackupTestsMixin(qubes.tests.SystemTestsMixin):
|
||||
orig_value = getattr(vm, prop)
|
||||
restored_value = getattr(restored_vm, prop)
|
||||
if orig_value and restored_value:
|
||||
self.assertEquals(orig_value.name, restored_value.name,
|
||||
self.assertEqual(orig_value.name, restored_value.name,
|
||||
"VM {} - property {} not properly restored".format(
|
||||
vm.name, prop))
|
||||
else:
|
||||
self.assertEquals(orig_value, restored_value,
|
||||
self.assertEqual(orig_value, restored_value,
|
||||
"VM {} - property {} not properly restored".format(
|
||||
vm.name, prop))
|
||||
for dev_class in vm.devices.keys():
|
||||
|
@ -126,7 +126,7 @@ class TC_01_Properties(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase):
|
||||
os.path.join(os.getenv("HOME"), ".local/share/applications",
|
||||
self.vmname + "-firefox.desktop")))
|
||||
self.vm.firewall.load()
|
||||
self.assertEquals(pre_rename_firewall, self.vm.firewall.rules)
|
||||
self.assertEqual(pre_rename_firewall, self.vm.firewall.rules)
|
||||
with self.assertNotRaises((qubes.exc.QubesException, OSError)):
|
||||
self.vm.firewall.save()
|
||||
self.assertTrue(self.vm.autostart)
|
||||
@ -171,24 +171,24 @@ class TC_01_Properties(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase):
|
||||
testvm1 = self.app.domains[testvm1.qid]
|
||||
testvm2 = self.app.domains[testvm2.qid]
|
||||
|
||||
self.assertEquals(testvm1.label, testvm2.label)
|
||||
self.assertEquals(testvm1.netvm, testvm2.netvm)
|
||||
self.assertEquals(testvm1.property_is_default('netvm'),
|
||||
self.assertEqual(testvm1.label, testvm2.label)
|
||||
self.assertEqual(testvm1.netvm, testvm2.netvm)
|
||||
self.assertEqual(testvm1.property_is_default('netvm'),
|
||||
testvm2.property_is_default('netvm'))
|
||||
self.assertEquals(testvm1.kernel, testvm2.kernel)
|
||||
self.assertEquals(testvm1.kernelopts, testvm2.kernelopts)
|
||||
self.assertEquals(testvm1.property_is_default('kernel'),
|
||||
self.assertEqual(testvm1.kernel, testvm2.kernel)
|
||||
self.assertEqual(testvm1.kernelopts, testvm2.kernelopts)
|
||||
self.assertEqual(testvm1.property_is_default('kernel'),
|
||||
testvm2.property_is_default('kernel'))
|
||||
self.assertEquals(testvm1.property_is_default('kernelopts'),
|
||||
self.assertEqual(testvm1.property_is_default('kernelopts'),
|
||||
testvm2.property_is_default('kernelopts'))
|
||||
self.assertEquals(testvm1.memory, testvm2.memory)
|
||||
self.assertEquals(testvm1.maxmem, testvm2.maxmem)
|
||||
self.assertEquals(testvm1.devices, testvm2.devices)
|
||||
self.assertEquals(testvm1.include_in_backups,
|
||||
self.assertEqual(testvm1.memory, testvm2.memory)
|
||||
self.assertEqual(testvm1.maxmem, testvm2.maxmem)
|
||||
self.assertEqual(testvm1.devices, testvm2.devices)
|
||||
self.assertEqual(testvm1.include_in_backups,
|
||||
testvm2.include_in_backups)
|
||||
self.assertEquals(testvm1.default_user, testvm2.default_user)
|
||||
self.assertEquals(testvm1.features, testvm2.features)
|
||||
self.assertEquals(testvm1.firewall.rules,
|
||||
self.assertEqual(testvm1.default_user, testvm2.default_user)
|
||||
self.assertEqual(testvm1.features, testvm2.features)
|
||||
self.assertEqual(testvm1.firewall.rules,
|
||||
testvm2.firewall.rules)
|
||||
|
||||
# now some non-default values
|
||||
@ -214,24 +214,24 @@ class TC_01_Properties(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase):
|
||||
testvm1 = self.app.domains[testvm1.qid]
|
||||
testvm3 = self.app.domains[testvm3.qid]
|
||||
|
||||
self.assertEquals(testvm1.label, testvm3.label)
|
||||
self.assertEquals(testvm1.netvm, testvm3.netvm)
|
||||
self.assertEquals(testvm1.property_is_default('netvm'),
|
||||
self.assertEqual(testvm1.label, testvm3.label)
|
||||
self.assertEqual(testvm1.netvm, testvm3.netvm)
|
||||
self.assertEqual(testvm1.property_is_default('netvm'),
|
||||
testvm3.property_is_default('netvm'))
|
||||
self.assertEquals(testvm1.kernel, testvm3.kernel)
|
||||
self.assertEquals(testvm1.kernelopts, testvm3.kernelopts)
|
||||
self.assertEquals(testvm1.property_is_default('kernel'),
|
||||
self.assertEqual(testvm1.kernel, testvm3.kernel)
|
||||
self.assertEqual(testvm1.kernelopts, testvm3.kernelopts)
|
||||
self.assertEqual(testvm1.property_is_default('kernel'),
|
||||
testvm3.property_is_default('kernel'))
|
||||
self.assertEquals(testvm1.property_is_default('kernelopts'),
|
||||
self.assertEqual(testvm1.property_is_default('kernelopts'),
|
||||
testvm3.property_is_default('kernelopts'))
|
||||
self.assertEquals(testvm1.memory, testvm3.memory)
|
||||
self.assertEquals(testvm1.maxmem, testvm3.maxmem)
|
||||
self.assertEquals(testvm1.devices, testvm3.devices)
|
||||
self.assertEquals(testvm1.include_in_backups,
|
||||
self.assertEqual(testvm1.memory, testvm3.memory)
|
||||
self.assertEqual(testvm1.maxmem, testvm3.maxmem)
|
||||
self.assertEqual(testvm1.devices, testvm3.devices)
|
||||
self.assertEqual(testvm1.include_in_backups,
|
||||
testvm3.include_in_backups)
|
||||
self.assertEquals(testvm1.default_user, testvm3.default_user)
|
||||
self.assertEquals(testvm1.features, testvm3.features)
|
||||
self.assertEquals(testvm1.firewall.rules,
|
||||
self.assertEqual(testvm1.default_user, testvm3.default_user)
|
||||
self.assertEqual(testvm1.features, testvm3.features)
|
||||
self.assertEqual(testvm1.firewall.rules,
|
||||
testvm2.firewall.rules)
|
||||
|
||||
def test_020_name_conflict_app(self):
|
||||
@ -294,7 +294,7 @@ class TC_02_QvmPrefs(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase):
|
||||
)
|
||||
(stdout, stderr) = p.communicate()
|
||||
if valid:
|
||||
self.assertEquals(p.returncode, 0,
|
||||
self.assertEqual(p.returncode, 0,
|
||||
"qvm-prefs .. '{}' '{}' failed: {}{}".format(
|
||||
name, value, stdout, stderr
|
||||
))
|
||||
@ -307,7 +307,7 @@ class TC_02_QvmPrefs(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase):
|
||||
p = subprocess.Popen(['qvm-prefs'] + self.sharedopts +
|
||||
['--', self.testvm.name, name], stdout=subprocess.PIPE)
|
||||
(stdout, _) = p.communicate()
|
||||
self.assertEquals(p.returncode, 0)
|
||||
self.assertEqual(p.returncode, 0)
|
||||
return stdout.strip()
|
||||
|
||||
bool_test_values = [
|
||||
@ -330,7 +330,7 @@ class TC_02_QvmPrefs(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase):
|
||||
for (value, expected, valid) in values:
|
||||
self.pref_set(name, value, valid)
|
||||
if valid:
|
||||
self.assertEquals(self.pref_get(name), expected)
|
||||
self.assertEqual(self.pref_get(name), expected)
|
||||
|
||||
@unittest.skip('test not converted to core3 API')
|
||||
def test_006_template(self):
|
||||
@ -421,7 +421,7 @@ class TC_03_QvmRevertTemplateChanges(qubes.tests.SystemTestsMixin,
|
||||
subprocess.check_call(revert_cmd)
|
||||
|
||||
checksum_after = self.get_rootimg_checksum()
|
||||
self.assertEquals(checksum_before, checksum_after)
|
||||
self.assertEqual(checksum_before, checksum_after)
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_000_revert_pv(self):
|
||||
@ -484,12 +484,12 @@ class TC_30_Gui_daemon(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase):
|
||||
|
||||
clipboard_content = \
|
||||
open('/var/run/qubes/qubes-clipboard.bin', 'r').read().strip()
|
||||
self.assertEquals(clipboard_content, test_string,
|
||||
self.assertEqual(clipboard_content, test_string,
|
||||
"Clipboard copy operation failed - content")
|
||||
clipboard_source = \
|
||||
open('/var/run/qubes/qubes-clipboard.bin.source',
|
||||
'r').read().strip()
|
||||
self.assertEquals(clipboard_source, testvm1.name,
|
||||
self.assertEqual(clipboard_source, testvm1.name,
|
||||
"Clipboard copy operation failed - owner")
|
||||
|
||||
# Then paste it to the other window
|
||||
@ -505,16 +505,16 @@ class TC_30_Gui_daemon(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase):
|
||||
# And compare the result
|
||||
(test_output, _) = self.loop.run_until_complete(
|
||||
testvm2.run_for_stdio('cat test.txt'))
|
||||
self.assertEquals(test_string, test_output.strip().decode('ascii'))
|
||||
self.assertEqual(test_string, test_output.strip().decode('ascii'))
|
||||
|
||||
clipboard_content = \
|
||||
open('/var/run/qubes/qubes-clipboard.bin', 'r').read().strip()
|
||||
self.assertEquals(clipboard_content, "",
|
||||
self.assertEqual(clipboard_content, "",
|
||||
"Clipboard not wiped after paste - content")
|
||||
clipboard_source = \
|
||||
open('/var/run/qubes/qubes-clipboard.bin.source', 'r').\
|
||||
read().strip()
|
||||
self.assertEquals(clipboard_source, "",
|
||||
self.assertEqual(clipboard_source, "",
|
||||
"Clipboard not wiped after paste - owner")
|
||||
|
||||
class TC_05_StandaloneVM(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase):
|
||||
@ -530,7 +530,7 @@ class TC_05_StandaloneVM(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase
|
||||
testvm1.clone_disk_files(self.app.default_template))
|
||||
self.app.save()
|
||||
self.loop.run_until_complete(testvm1.start())
|
||||
self.assertEquals(testvm1.get_power_state(), "Running")
|
||||
self.assertEqual(testvm1.get_power_state(), "Running")
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_100_resize_root_img(self):
|
||||
@ -541,7 +541,7 @@ class TC_05_StandaloneVM(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase
|
||||
self.app.save()
|
||||
self.loop.run_until_complete(
|
||||
testvm1.storage.resize(testvm1.volumes['root'], 20 * 1024 ** 3))
|
||||
self.assertEquals(testvm1.volumes['root'].size, 20 * 1024 ** 3)
|
||||
self.assertEqual(testvm1.volumes['root'].size, 20 * 1024 ** 3)
|
||||
self.loop.run_until_complete(testvm1.start())
|
||||
# new_size in 1k-blocks
|
||||
(new_size, _) = self.loop.run_until_complete(
|
||||
|
@ -53,7 +53,7 @@ class TC_04_DispVM(qubes.tests.SystemTestsMixin,
|
||||
p = self.testvm.run("qvm-run --dispvm bash", passio_popen=True)
|
||||
(stdout, _) = p.communicate(input=b"echo test; qubesdb-read /name; "
|
||||
b"echo ERROR\n")
|
||||
self.assertEquals(p.returncode, 0)
|
||||
self.assertEqual(p.returncode, 0)
|
||||
lines = stdout.decode('ascii').splitlines()
|
||||
self.assertEqual(lines[0], "test")
|
||||
dispvm_name = lines[1]
|
||||
@ -84,7 +84,7 @@ class TC_04_DispVM(qubes.tests.SystemTestsMixin,
|
||||
time.sleep(1)
|
||||
timeout -= 1
|
||||
# includes check for None - timeout
|
||||
self.assertEquals(p.returncode, 0)
|
||||
self.assertEqual(p.returncode, 0)
|
||||
lines = p.stdout.read().splitlines()
|
||||
self.assertTrue(lines, 'No output received from DispVM')
|
||||
dispvm_name = lines[0]
|
||||
|
@ -71,7 +71,7 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin):
|
||||
|
||||
def test_000_start_shutdown(self):
|
||||
self.loop.run_until_complete(self.testvm1.start())
|
||||
self.assertEquals(self.testvm1.get_power_state(), "Running")
|
||||
self.assertEqual(self.testvm1.get_power_state(), "Running")
|
||||
self.loop.run_until_complete(self.testvm1.shutdown())
|
||||
|
||||
shutdown_counter = 0
|
||||
@ -81,13 +81,13 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin):
|
||||
shutdown_counter += 1
|
||||
time.sleep(1)
|
||||
time.sleep(1)
|
||||
self.assertEquals(self.testvm1.get_power_state(), "Halted")
|
||||
self.assertEqual(self.testvm1.get_power_state(), "Halted")
|
||||
|
||||
@unittest.skipUnless(spawn.find_executable('xdotool'),
|
||||
"xdotool not installed")
|
||||
def test_010_run_xterm(self):
|
||||
self.loop.run_until_complete(self.testvm1.start())
|
||||
self.assertEquals(self.testvm1.get_power_state(), "Running")
|
||||
self.assertEqual(self.testvm1.get_power_state(), "Running")
|
||||
|
||||
p = self.loop.run_until_complete(self.testvm1.run('xterm'))
|
||||
try:
|
||||
@ -97,8 +97,7 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin):
|
||||
title = 'user@host'
|
||||
while subprocess.call(
|
||||
['xdotool', 'search', '--name', title],
|
||||
stdout=open(os.path.devnull, 'w'),
|
||||
stderr=subprocess.STDOUT) > 0:
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) > 0:
|
||||
wait_count += 1
|
||||
if wait_count > 100:
|
||||
self.fail("Timeout while waiting for xterm window")
|
||||
@ -128,7 +127,7 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin):
|
||||
if "minimal" in self.template:
|
||||
self.skipTest("Minimal template doesn't have 'gnome-terminal'")
|
||||
self.loop.run_until_complete(self.testvm1.start())
|
||||
self.assertEquals(self.testvm1.get_power_state(), "Running")
|
||||
self.assertEqual(self.testvm1.get_power_state(), "Running")
|
||||
p = self.loop.run_until_complete(self.testvm1.run('gnome-terminal'))
|
||||
try:
|
||||
title = 'user@{}'.format(self.testvm1.name)
|
||||
@ -167,7 +166,7 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin):
|
||||
@unittest.expectedFailure
|
||||
def test_012_qubes_desktop_run(self):
|
||||
self.loop.run_until_complete(self.testvm1.start())
|
||||
self.assertEquals(self.testvm1.get_power_state(), "Running")
|
||||
self.assertEqual(self.testvm1.get_power_state(), "Running")
|
||||
xterm_desktop_path = "/usr/share/applications/xterm.desktop"
|
||||
# Debian has it different...
|
||||
xterm_desktop_path_debian = \
|
||||
@ -224,7 +223,7 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin):
|
||||
self.fail(
|
||||
"Timeout, probably EOF wasn't transferred to the VM process")
|
||||
|
||||
self.assertEquals(stdout, TEST_DATA,
|
||||
self.assertEqual(stdout, TEST_DATA,
|
||||
'Received data differs from what was sent')
|
||||
self.assertFalse(stderr,
|
||||
'Some data was printed to stderr')
|
||||
@ -243,7 +242,7 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin):
|
||||
p.stdin.write(TEST_DATA)
|
||||
yield from p.stdin.drain()
|
||||
p.stdin.close()
|
||||
self.assertEquals(stdout.strip(), 'test',
|
||||
self.assertEqual(stdout.strip(), 'test',
|
||||
'Received data differs from what was expected')
|
||||
# this may hang in some buggy cases
|
||||
self.assertFalse((yield from p.stderr.read()),
|
||||
@ -280,7 +279,7 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin):
|
||||
except asyncio.TimeoutError:
|
||||
self.fail("Timeout, probably EOF wasn't transferred")
|
||||
|
||||
self.assertEquals(stdout, b'test',
|
||||
self.assertEqual(stdout, b'test',
|
||||
'Received data differs from what was expected')
|
||||
|
||||
@unittest.expectedFailure
|
||||
@ -304,7 +303,7 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin):
|
||||
except asyncio.TimeoutError:
|
||||
self.fail("Timeout, probably EOF wasn't transferred")
|
||||
|
||||
self.assertEquals(stdout, b'test',
|
||||
self.assertEqual(stdout, b'test',
|
||||
'Received data differs from what was expected')
|
||||
|
||||
def test_055_qrexec_dom0_service_abort(self):
|
||||
|
@ -82,7 +82,7 @@ class TC_00_FilePool(qubes.tests.QubesTestCase):
|
||||
"""
|
||||
result = self.app.get_pool("default").dir_path
|
||||
expected = '/var/lib/qubes'
|
||||
self.assertEquals(result, expected)
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
def test001_default_storage_class(self):
|
||||
""" Check when using default pool the Storage is
|
||||
@ -244,7 +244,7 @@ class TC_01_FileVolumes(qubes.tests.QubesTestCase):
|
||||
volumes = vm.volumes
|
||||
b_dev = volumes[dev_name].block_device()
|
||||
self.assertEqual(b_dev.rw, rw)
|
||||
self.assertEquals(b_dev.path, expected)
|
||||
self.assertEqual(b_dev.path, expected)
|
||||
|
||||
|
||||
class TC_03_FilePool(qubes.tests.QubesTestCase):
|
||||
@ -319,12 +319,12 @@ class TC_03_FilePool(qubes.tests.QubesTestCase):
|
||||
expected_vmdir = os.path.join(self.APPVMS_DIR, vm.name)
|
||||
|
||||
expected_private_path = os.path.join(expected_vmdir, 'private.img')
|
||||
self.assertEquals(vm.volumes['private'].path, expected_private_path)
|
||||
self.assertEqual(vm.volumes['private'].path, expected_private_path)
|
||||
|
||||
expected_volatile_path = os.path.join(expected_vmdir, 'volatile.img')
|
||||
vm.storage.get_pool(vm.volumes['volatile'])\
|
||||
.reset(vm.volumes['volatile'])
|
||||
self.assertEqualsAndExists(vm.volumes['volatile'].path,
|
||||
self.assertEqualAndExists(vm.volumes['volatile'].path,
|
||||
expected_volatile_path)
|
||||
|
||||
def test_013_template_file_images(self):
|
||||
@ -353,25 +353,25 @@ class TC_03_FilePool(qubes.tests.QubesTestCase):
|
||||
expected_root_cow_path = os.path.join(expected_vmdir, 'root-cow.img')
|
||||
expected_root_path = '%s:%s' % (expected_root_origin_path,
|
||||
expected_root_cow_path)
|
||||
self.assertEquals(vm.volumes['root'].block_device().path,
|
||||
self.assertEqual(vm.volumes['root'].block_device().path,
|
||||
expected_root_path)
|
||||
self.assertExist(vm.volumes['root'].path)
|
||||
|
||||
expected_private_path = os.path.join(expected_vmdir, 'private.img')
|
||||
self.assertEqualsAndExists(vm.volumes['private'].path,
|
||||
self.assertEqualAndExists(vm.volumes['private'].path,
|
||||
expected_private_path)
|
||||
|
||||
expected_rootcow_path = os.path.join(expected_vmdir, 'root-cow.img')
|
||||
self.assertEqualsAndExists(vm.volumes['root'].path_cow,
|
||||
self.assertEqualAndExists(vm.volumes['root'].path_cow,
|
||||
expected_rootcow_path)
|
||||
|
||||
def assertEqualsAndExists(self, result_path, expected_path):
|
||||
def assertEqualAndExists(self, result_path, expected_path):
|
||||
""" Check if the ``result_path``, matches ``expected_path`` and exists.
|
||||
|
||||
See also: :meth:``assertExist``
|
||||
"""
|
||||
# :pylint: disable=invalid-name
|
||||
self.assertEquals(result_path, expected_path)
|
||||
self.assertEqual(result_path, expected_path)
|
||||
self.assertExist(result_path)
|
||||
|
||||
def assertExist(self, path):
|
||||
|
@ -159,13 +159,13 @@ class QubesVMTestsMixin(object):
|
||||
# single exception?
|
||||
with self.assertNotRaises((ValueError, TypeError, KeyError)):
|
||||
setattr(vm, prop_name, set_value)
|
||||
self.assertEquals(getattr(vm, prop_name), expected_value)
|
||||
self.assertEqual(getattr(vm, prop_name), expected_value)
|
||||
if expected_xml_content is not None:
|
||||
xml = vm.__xml__()
|
||||
prop_xml = xml.xpath(
|
||||
'./properties/property[@name=\'{}\']'.format(prop_name))
|
||||
self.assertEquals(len(prop_xml), 1, "Property not found in XML")
|
||||
self.assertEquals(prop_xml[0].text, expected_xml_content)
|
||||
self.assertEqual(len(prop_xml), 1, "Property not found in XML")
|
||||
self.assertEqual(prop_xml[0].text, expected_xml_content)
|
||||
|
||||
def assertPropertyInvalidValue(self, vm, prop_name, set_value):
|
||||
orig_value_set = True
|
||||
@ -179,7 +179,7 @@ class QubesVMTestsMixin(object):
|
||||
with self.assertRaises((ValueError, TypeError, KeyError)):
|
||||
setattr(vm, prop_name, set_value)
|
||||
if orig_value_set:
|
||||
self.assertEquals(getattr(vm, prop_name), orig_value)
|
||||
self.assertEqual(getattr(vm, prop_name), orig_value)
|
||||
else:
|
||||
with self.assertRaises(AttributeError):
|
||||
getattr(vm, prop_name)
|
||||
@ -191,11 +191,11 @@ class QubesVMTestsMixin(object):
|
||||
getattr(vm, prop_name)
|
||||
else:
|
||||
with self.assertNotRaises(AttributeError):
|
||||
self.assertEquals(getattr(vm, prop_name), expected_default)
|
||||
self.assertEqual(getattr(vm, prop_name), expected_default)
|
||||
xml = vm.__xml__()
|
||||
prop_xml = xml.xpath(
|
||||
'./properties/property[@name=\'{}\']'.format(prop_name))
|
||||
self.assertEquals(len(prop_xml), 0, "Property still found in XML")
|
||||
self.assertEqual(len(prop_xml), 0, "Property still found in XML")
|
||||
|
||||
def _test_generic_bool_property(self, vm, prop_name, default=False):
|
||||
self.assertPropertyDefaultValue(vm, prop_name, default)
|
||||
|
@ -97,9 +97,10 @@ class AdminVM(qubes.vm.qubesvm.QubesVM):
|
||||
'''
|
||||
|
||||
# return psutil.virtual_memory().total/1024
|
||||
for line in open('/proc/meminfo'):
|
||||
if line.startswith('MemTotal:'):
|
||||
return int(line.split(':')[1].strip().split()[0])
|
||||
with open('/proc/meminfo') as file:
|
||||
for line in file:
|
||||
if line.startswith('MemTotal:'):
|
||||
return int(line.split(':')[1].strip().split()[0])
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_mem_static_max(self):
|
||||
|
Loading…
Reference in New Issue
Block a user