Unit test advice request

Hi all
written a unit test that works OK in my dev notebook here but fails in HA after successful creation of the sensor here. Any advice?
Cheers

    @patch('os.stat', Mock(return_value=FAKE))
    def test_filesize_class(self):
        self.assertTrue(
            setup_component(self.hass, 'sensor', {'sensor': self.config}))

        state = self.hass.states.get('sensor.homeassistant_v2db')

>       assert state.state == 37.99
E       AttributeError: 'NoneType' object has no attribute 'state'