From: Jean-Paul C. <ex...@di...> - 2008-10-17 13:34:14
|
On Sat, 18 Oct 2008 00:07:29 +1100, Morgan Reed <mor...@gm...> wrote: >I've started writing unit tests for my additions now, I've got an >issue though, I've updated test_crypto.py changes summarised below; > >================================================ > >from OpenSSL.crypto import RSA, RSAType > >... > >class RSATests(TestCase, _Python23TestCaseHelper): > > def test_construction(self): > """ > L{RSA} takes no arguments and returns an instance of L{RSAType}. > """ > rsaobj = RSA() > self.assertTrue( > isinstance(rsaobj, RSAType), > "%r is of type %r, should be %r" % (rsaobj, > type(rsaobj), > RSAType)) > > def test_generate_key(self): > """ > L{generate_key} generates a new RSA key the given size and stores it in > the internal structure > """ > bits = 1024 > rsaobj = RSA() > rsaobj.generate_key(bits) > self.assertEqual(rsaobj.key_bits(), bits) > >================================================ > >When I execute the tests only test_construction is being executed (or >it's the only one appearing in the log), is there anything I need to >do besides defining the test method in the test class? (apologies for >the basic questions, I've never done automated unit testing in python >before) > The code you included looks right. I would certainly expect two tests to be run, test_construction and test_generate_key, if I ran a command like "trial OpenSSL.test.test_crypto.RSATests", after doing the needed song and dance to get the code and tests into a state where they could be imported. Jean-Paul |