MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / test_get_swap_size_linux

Method test_get_swap_size_linux

tests/TestMemory.py:119–135  ·  view source on GitHub ↗

Test for get_swap_size_linux()

(self)

Source from the content-addressed store, hash-verified

117
118 @common.skipIfWindows
119 def test_get_swap_size_linux(self):
120 """Test for get_swap_size_linux()"""
121 if not exe_exists('swapon'):
122 self.skipTest('swapon not found')
123 with open('/proc/swaps') as f:
124 swapdev = f.read().split('\n')[1].split(' ')[0]
125 if 0 == len(swapdev):
126 self.skipTest('no active swap device detected')
127 size = get_swap_size_linux(swapdev)
128 self.assertIsInteger(size)
129 self.assertGreater(size, 1024 ** 2)
130 logger.debug("size of swap '%s': %d B (%d MB)",
131 swapdev, size, size / (1024 ** 2))
132 with open('/proc/swaps') as f:
133 proc_swaps = f.read()
134 size2 = get_swap_size_linux(swapdev, proc_swaps)
135 self.assertEqual(size, size2)
136
137 @common.skipIfWindows
138 def test_get_swap_uuid(self):

Callers

nothing calls this directly

Calls 4

exe_existsFunction · 0.90
get_swap_size_linuxFunction · 0.90
readMethod · 0.80
assertIsIntegerMethod · 0.80

Tested by

no test coverage detected