def test_a_scenario_with_mock_subprocess(self, mock_popen):
    mock_popen.return_value.communicate.return_value = 'Expected_value', ''
mock_popen.return_value.returncode = '0'
self.assertEqual('expected_value', get_drive_size('some device'))
How to unit test program interacting with block devices