Re: [Launchpad-dev] New feature in Launchpad TestCase base class
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/24/2010 05:49 AM, James Westby wrote: Hi, I've just landed a change to use the great testtools feature of result attachments (addDetails()) to attach any generated oops to the result. Are you handling cases where the test reconfigures the oops handler or uses its own instead of the global? Aaron -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxNqpYACgkQ0F+nu1YWqI2AhACcDo3te2cDbKHeG5Y+QmEoPxVH VbgAnRspE7AOtv1wenw5+99U0lBE52po =lK6H -END PGP SIGNATURE- ___ Mailing list: https://launchpad.net/~launchpad-dev Post to : launchpad-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-dev More help : https://help.launchpad.net/ListHelp
Re: [Launchpad-dev] New feature in Launchpad TestCase base class
On Mon, 26 Jul 2010 11:32:38 -0400, Aaron Bentley aa...@canonical.com wrote: Are you handling cases where the test reconfigures the oops handler or uses its own instead of the global? I don't know, Tim? Thanks, James ___ Mailing list: https://launchpad.net/~launchpad-dev Post to : launchpad-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-dev More help : https://help.launchpad.net/ListHelp
Re: [Launchpad-dev] New feature in Launchpad TestCase base class
On Tue, 27 Jul 2010 04:14:40 James Westby wrote: On Mon, 26 Jul 2010 11:32:38 -0400, Aaron Bentley aa...@canonical.com wrote: Are you handling cases where the test reconfigures the oops handler or uses its own instead of the global? I don't know, Tim? If the test reconfigures the oops handler, the original function won't be called, so the event won't be raised, and the event listener won't be fired. So... if the oops handler function is monkey patched, the test case won't know. Tim ___ Mailing list: https://launchpad.net/~launchpad-dev Post to : launchpad-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-dev More help : https://help.launchpad.net/ListHelp
Re: [Launchpad-dev] New feature in Launchpad TestCase base class
Hi, I've just landed a change to use the great testtools feature of result attachments (addDetails()) to attach any generated oops to the result. I did this after I broke XMLRPC and had several tests that just failed with an OOPS id on the xmlrpc client side. On Tue, 4 May 2010 10:38:11 +0100, Jonathan Lange j...@canonical.com wrote: Perhaps we should go a step further and fail tests if they generate any oopses? It would be easy enough to provide a method that flushes out the stored oopses list. I think it would be good to do this as well. I'm unsure about a method to clear self.oopses though, as it could mask issues. How about def clearOopses(self, count=1): self.assertEqual( count, len(self.oopses), There were an unexpected number of oops generated by this test: expected %d, got %d. % (count, len(self.oopses))) self.oopses = [] This will ensure that if you manage to trigger two oops when you expect only one you will get a failure, and the code I just landed will make sure that you can see them. Thanks, James ___ Mailing list: https://launchpad.net/~launchpad-dev Post to : launchpad-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-dev More help : https://help.launchpad.net/ListHelp
Re: [Launchpad-dev] New feature in Launchpad TestCase base class
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/03/2010 09:47 PM, Tim Penhey wrote: This uses a Fixture that jml wrote a while ago for the scanner (which has since been removed). The fixture code was moved to lp.testing.fixture. If you have a need to use something in your tests that has a setUp and tearDown, you can define a fixture, and use the TestCase method installFixture. This sounds a lot like a Context Manager. Should they be unified? If not, how should we choose which to use? Aaron -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkvgIh0ACgkQ0F+nu1YWqI3seQCZAUj5OmttkMJye4rzC9ySnS27 dE8Anj0UrLT3GqM2KErZ4FLuepXRwPe6 =hjrl -END PGP SIGNATURE- ___ Mailing list: https://launchpad.net/~launchpad-dev Post to : launchpad-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-dev More help : https://help.launchpad.net/ListHelp
Re: [Launchpad-dev] New feature in Launchpad TestCase base class
On Tue, May 4, 2010 at 2:33 PM, Aaron Bentley aa...@canonical.com wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/03/2010 09:47 PM, Tim Penhey wrote: This uses a Fixture that jml wrote a while ago for the scanner (which has since been removed). The fixture code was moved to lp.testing.fixture. If you have a need to use something in your tests that has a setUp and tearDown, you can define a fixture, and use the TestCase method installFixture. This sounds a lot like a Context Manager. Should they be unified? If not, how should we choose which to use? They serve a similar purpose, to be sure. Please forgive me, but the best way I can answer right now is to think out loud and not come to a conclusion. I hope it helps. A bunch of things have setUp and tearDown methods, things like bzr Server objects. Some of these things are relatively complicated and benefit from having an addCleanup method. Hence, the Fixture base class. I'm going to call anything with a setUp and tearDown method a fixture for the rest of this email. Since these fixtures are frequently used in tests, it's nice to have a convenient way of saying run this test with this fixture. Especially since fixture.setUp(); self.addCleanup(fixture.tearDown) is boilerplate. self.installFixture(FooFixture()) seems as good a way as any, especially in Python 2.4 land. In Python 2.5 land, we have Context Managers. I guess any test that uses addCleanup now (never mind Fixture) could be rewritten to use a context manager instead. I'm genuinely uncertain as to whether that would be an improvement, but guess not. It would certainly be nice to have something like installFixture that takes a Context Manager instead of a thing that has setUp and tearDown. It would probably be nice to have a thing that adapts objects with setUp/tearDown and turns them into Context Managers, since it would eliminate the need for two methods that do basically the same thing, and since it would let us use things like bzr Servers with the 'with' notation. Maybe Launchpad classes that have setUp and tearDown (like Fixture) should be changed to be context managers. I genuinely don't know whether that would be an improvement. I don't really know how many we have (excluding tests). I also don't know how many context managers we have. jml ___ Mailing list: https://launchpad.net/~launchpad-dev Post to : launchpad-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-dev More help : https://help.launchpad.net/ListHelp
[Launchpad-dev] New feature in Launchpad TestCase base class
Hi All, In my continued mission to make things easier to test, I've added a new feature to the base TestCase class in lp.testing (this makes it in TestCaseWithFactory too). r9327 of db-devel (will be rolled out tonight) contains this change. The test case class now has an oopses attribute. This is a list that gets any oops generated as part of the test appended as it is generated. This gives any test a deterministic way to determine if any oopses were generated. Tim -- the magic The error reporting utility now notifies listeners when a new oops is generated using an IErrorReportEvent (which is an object event). The setUp method of the test case adds a listener, and adds the cleanup to remove the listener after tearDown. This uses a Fixture that jml wrote a while ago for the scanner (which has since been removed). The fixture code was moved to lp.testing.fixture. If you have a need to use something in your tests that has a setUp and tearDown, you can define a fixture, and use the TestCase method installFixture. ___ Mailing list: https://launchpad.net/~launchpad-dev Post to : launchpad-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-dev More help : https://help.launchpad.net/ListHelp