예제 #1
0
        def test_find_all_exception(self):
            with patch.object(Ftdi, 'find_all', side_effect=[USBError('testing'), FtdiError]) as mock:
                with self.assertRaises(CommError):
                    devices = USBDevice.find_all()

                with self.assertRaises(CommError):
                    devices = USBDevice.find_all()
예제 #2
0
        def test_events(self):
            self.assertFalse(self._attached)
            self.assertFalse(self._detached)

            # this is ugly, but it works.
            with patch.object(USBDevice, 'find_all', return_value=[(0, 0, 'AD2-1', 1, 'AD2'), (0, 0, 'AD2-2', 1, 'AD2')]):
                USBDevice.start_detection(on_attached=self.attached_event, on_detached=self.detached_event)

                with patch.object(USBDevice, 'find_all', return_value=[(0, 0, 'AD2-2', 1, 'AD2')]):
                    USBDevice.find_all()
                    time.sleep(1)
                    USBDevice.stop_detection()

            self.assertTrue(self._attached)
            self.assertTrue(self._detached)
예제 #3
0
    def test_find_all(self):
        with patch.object(USBDevice, 'find_all', return_value=[]) as mock:
            devices = USBDevice.find_all()

        self.assertEqual(devices, [])
예제 #4
0
        def test_find_all(self):
            with patch.object(USBDevice, 'find_all', return_value=[]) as mock:
                devices = USBDevice.find_all()

            self.assertEquals(devices, [])