예제 #1
0
    def test_with_reraises_exception(self):
        descriptor, driver = make_mocks()

        with self.assertRaises(TestSpecificError):
            with YubiKey(descriptor, driver):
                raise TestSpecificError()

        driver.close.assert_called_once_with()
예제 #2
0
 def _get_dev_from_reader(self):
     readers = list(open_ccid(self._reader_filter))
     if len(readers) == 1:
         drv = readers[0]
         return YubiKey(Descriptor.from_driver(drv), drv)
     return None
예제 #3
0
 def test_with_closes_driver(self):
     descriptor, driver = make_mocks()
     with YubiKey(descriptor, driver):
         pass
     driver.close.assert_called_once_with()
예제 #4
0
 def test_with_as_closes_driver(self):
     descriptor, driver = make_mocks()
     with YubiKey(descriptor, driver) as dev:  # noqa: F841
         pass
     driver.close.assert_called_once_with()