def test_get_volume_size(self): executes = [] def fake_execute(*cmd, **kwargs): executes.append(cmd) return 123456789, None expected_commands = [('blockdev', '--getsize64', '/dev/foo')] self.stubs.Set(utils, 'execute', fake_execute) size = lvm.get_volume_size('/dev/foo') self.assertEqual(expected_commands, executes) self.assertEqual(size, 123456789)