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()
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
def test_with_closes_driver(self): descriptor, driver = make_mocks() with YubiKey(descriptor, driver): pass driver.close.assert_called_once_with()
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()