@@ -0,0 +1,1726 @@
+#! /usr/bin/env python%0A# -*- coding: utf-8 -*-%0A%0A# to execute:%0A# $ cd test%0A# $ python -m unittest%0A%0Aimport unittest%0Afrom smartcard.Exceptions import *%0Afrom smartcard.scard import *%0A%0A%0Aclass TestUtil(unittest.TestCase):%0A%0A    def test_Exceptions(self):%0A        exc = SmartcardException()%0A        self.assertEqual(exc.hresult, -1)%0A%0A%0A    def test_ListReadersException(self):%0A        exc = ListReadersException(0)%0A        self.assertEqual(exc.hresult, 0)%0A        text = str(exc)%0A        self.assertEqual(text, %22Failed to list readers: Command successful. (0x00000000)%22)%0A%0A        exc = ListReadersException(0x42)%0A        self.assertEqual(exc.hresult, 0x42)%0A        text = str(exc)%0A        self.assertEqual(text, %22Failed to list readers: Unknown error: 0x00000042 (0x00000042)%22)%0A%0A        exc = ListReadersException(SCARD_S_SUCCESS)%0A        self.assertEqual(exc.hresult, 0)%0A%0A        exc = ListReadersException(SCARD_E_NO_SERVICE)%0A        self.assertEqual(exc.hresult, 0x8010001D)%0A        text = str(exc)%0A        self.assertEqual(text, %22Failed to list readers: Service not available. (0x8010001D)%22)%0A%0A    def test_NoReadersException(self):%0A        exc = NoReadersException()%0A        self.assertEqual(exc.hresult, -1)%0A        text = str(exc)%0A        self.assertEqual(text, %22No reader found%22)%0A%0A    def test_InvalidReaderException(self):%0A        exc = InvalidReaderException(%22foobar%22)%0A        self.assertEqual(exc.hresult, -1)%0A        text = str(exc)%0A        self.assertEqual(text, %22Invalid reader: foobar%22)%0A%0A    def test_CardConnectionException(self):%0A        exc= CardConnectionException()%0A        self.assertEqual(exc.hresult, -1)%0A        text = str(exc)%0A        self.assertEqual(text, %22%22)%0A%0A%0Aif __name__ == '__main__':%0A    unittest.main()%0A

add unit tests for Exceptions