def test_extrareport(self, mock_open):
     # should read some files from sysfs e.g. /sys/block/fake/removable
     # in order to get some device properties
     def with_side_effect(arg):
         mock_with = mock.MagicMock()
         mock_with.__exit__.return_value = None
         mock_file = mock.Mock()
         if arg == '/sys/block/fake/removable':
             mock_file.read.return_value = '0\n'
         elif arg == '/sys/block/fake/device/state':
             mock_file.read.return_value = 'running\n'
         elif arg == '/sys/block/fake/device/timeout':
             mock_file.read.return_value = '30\n'
         mock_with.__enter__.return_value = mock_file
         return mock_with
     mock_open.side_effect = with_side_effect
     expected = {'removable': '0', 'state': 'running', 'timeout': '30'}
     self.assertEqual(expected, hu.extrareport('/dev/fake'))
 def test_extrareport(self, mock_open):
     # should read some files from sysfs e.g. /sys/block/fake/removable
     # in order to get some device properties
     def with_side_effect(arg):
         mock_with = mock.MagicMock()
         mock_with.__exit__.return_value = None
         mock_file = mock.Mock()
         if arg == '/sys/block/fake/removable':
             mock_file.read.return_value = '0\n'
         elif arg == '/sys/block/fake/device/state':
             mock_file.read.return_value = 'running\n'
         elif arg == '/sys/block/fake/device/timeout':
             mock_file.read.return_value = '30\n'
         mock_with.__enter__.return_value = mock_file
         return mock_with
     mock_open.side_effect = with_side_effect
     expected = {'removable': '0', 'state': 'running', 'timeout': '30'}
     self.assertEqual(expected, hu.extrareport('/dev/fake'))
 def test_extrareport_exceptions(self, mock_open):
     mock_open.side_effect = Exception('foo')
     expected = {}
     self.assertEqual(expected, hu.extrareport('/dev/fake'))