New! Writing doctests for Trac plugins WAS: [Trac] Re: Writing tests for Trac plugins : How ?
On Tue, Jul 21, 2009 at 12:51 AM, Chris Heller chris.heller.greysparl...@gmail.com wrote: There are numerous plugins on trac-hacks that have unittest based tests. Thanks all for your suggestions and comments. I have been preparing the next release (coming soon ;o) of TracGviz 1.4.1 and I've been (finally) able to publish the repos [1]_ containing most of the work been done so far. In there (`providers` branch) you can find the doctests I've written to test Trac RPC handlers. All this has been implemented on top of `dutest` module and is the first instance (that I know ... CMIIW) of both a dutest-based framework for particular purposes thus hiding details about initialization and cleanup , and a framework to write doctests for Trac plugins. All tests pass using TracXmlRpc=1.0.0 and failures with TracXmlRpc=1.0.6 have only been detected in ReportRPC (/me working on it :-/ ) Here are some handy starting points for exploration. [...] «Starting points for exploration» are here [2]_ [3]_ ;o) Needless to say that there's a lot of place for enhancements in there (especially tests for multi-protocol RPC, for repositories, and in-process web testing ...) but at least you can get the idea of the style and so on . Once I write further test cases they will show up ;o) Feedback is welcome ! PS: C'u soon with a new release of TracGViz plugin ... Happy New Year ! o|:o) .. [1] TracGViz Hg @ sf.net (http://simelo.hg.sourceforge.net/hgweb/simelo/trac-gviz/summary) .. [2] Test cases (i.e. doctests) for RPC providers in TracGViz plugin (http://simelo.hg.sourceforge.net/hgweb/simelo/trac-gviz/file/providers/trac-dev/gviz/tracgviz/testing/test_rpc.py) .. [3] Minimalistic testing framework for Trac (http://simelo.hg.sourceforge.net/hgweb/simelo/trac-gviz/file/providers/trac-dev/gviz/tracgviz/testing/__init__.py) -- Regards, Olemis. Blog ES: http://simelo-es.blogspot.com/ Blog EN: http://simelo-en.blogspot.com/ Featured article: Assessment of unittest 2.7 API : new features and opinions - http://feedproxy.google.com/~r/simelo-en/~3/cVOgG8NIBFY/assessment-of-unittest-27-api-new.html -- You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-us...@googlegroups.com. To unsubscribe from this group, send email to trac-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.
[Trac] Re: Writing tests for Trac plugins : How ?
On Mon, Jul 20, 2009 at 08:47:21AM -0500, Olemis Lang wrote: This time my question is very simple (even if `simple` is relative :P) : - Is it possible to write and run tests for Trac plugins ? Of course! You can write tests for damned near anything. - How ? I mean what are the best practices, procedures, steps (or whatever ;o) to do it. Shoot, I wish I knew. I'd love to know myself. - Does any of those integrates with `unittest` ? If you want it to. I don't know, any insight from someone with more knowledge to someone like myself that wants to write tests but is not sure what the best form is? Thnx in advance ! -- Regards, Olemis. Blog ES: http://simelo-es.blogspot.com/ Blog EN: http://simelo-en.blogspot.com/ Featured article: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to trac-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: Writing tests for Trac plugins : How ?
On 7/20/09, Jeff Hammel jham...@openplans.org wrote: On Mon, Jul 20, 2009 at 08:47:21AM -0500, Olemis Lang wrote: This time my question is very simple (even if `simple` is relative :P) : - Is it possible to write and run tests for Trac plugins ? Of course! You can write tests for damned near anything. Well concerning test frameworks (e.g. `unittest`, `doctest` ...) I imagine (I'm sure ?) it's possible. but in the case of Trac plugins there is a peculiar characteristic: - How do I get an env populated with the test data ? - How do I mock things ? - How can I setup (in the test code) the test env so that it can load my plugin ? - How ? I mean what are the best practices, procedures, steps (or whatever ;o) to do it. Shoot, I wish I knew. I'd love to know myself. The former are just a few questions (doubts ?) I have. I could start writing all that from scratch using any testing framework, but I imagine that you already have shortcuts for this (isnt it ? oh ! please tell me so :( ... ). - Does any of those integrates with `unittest` ? If you want it to. I don't know, any insight from someone with more knowledge to someone like myself that wants to write tests but is not sure what the best form is? Well I've seen some doctests in Trac package written (which could be integrated with `unittest` by using `dutest` ;o) and it seems that `twill` is around (which is *COOL* :), but the doubts I have are just about existing shortcuts (if any) in order to use all that to test Trac plugins too ;o) -- Regards, Olemis. Blog ES: http://simelo-es.blogspot.com/ Blog EN: http://simelo-en.blogspot.com/ Featured article: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to trac-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: Writing tests for Trac plugins : How ?
On Mon, Jul 20, 2009 at 09:29:22AM -0500, Olemis Lang wrote: On 7/20/09, Jeff Hammel jham...@openplans.org wrote: On Mon, Jul 20, 2009 at 08:47:21AM -0500, Olemis Lang wrote: This time my question is very simple (even if `simple` is relative :P) : - Is it possible to write and run tests for Trac plugins ? Of course! You can write tests for damned near anything. Well concerning test frameworks (e.g. `unittest`, `doctest` ...) I imagine (I'm sure ?) it's possible. but in the case of Trac plugins there is a peculiar characteristic: - How do I get an env populated with the test data ? - How do I mock things ? - How can I setup (in the test code) the test env so that it can load my plugin ? - How ? I mean what are the best practices, procedures, steps (or whatever ;o) to do it. Shoot, I wish I knew. I'd love to know myself. The former are just a few questions (doubts ?) I have. I could start writing all that from scratch using any testing framework, but I imagine that you already have shortcuts for this (isnt it ? oh ! please tell me so :( ... ). No, sadly, my shortcut is not to write tests because its difficult and because I don't know if there is a testing framework and I haven't had time to write one myself :( Hence me revoicing your concerns - Does any of those integrates with `unittest` ? If you want it to. I don't know, any insight from someone with more knowledge to someone like myself that wants to write tests but is not sure what the best form is? Well I've seen some doctests in Trac package written (which could be integrated with `unittest` by using `dutest` ;o) and it seems that `twill` is around (which is *COOL* :), but the doubts I have are just about existing shortcuts (if any) in order to use all that to test Trac plugins too ;o) -- Regards, Olemis. Blog ES: http://simelo-es.blogspot.com/ Blog EN: http://simelo-en.blogspot.com/ Featured article: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to trac-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: Writing tests for Trac plugins : How ?
On 7/20/09, Jeff Hammel jham...@openplans.org wrote: On Mon, Jul 20, 2009 at 09:29:22AM -0500, Olemis Lang wrote: On 7/20/09, Jeff Hammel jham...@openplans.org wrote: On Mon, Jul 20, 2009 at 08:47:21AM -0500, Olemis Lang wrote: Well concerning test frameworks (e.g. `unittest`, `doctest` ...) I imagine (I'm sure ?) it's possible. but in the case of Trac plugins there is a peculiar characteristic: - How do I get an env populated with the test data ? - How do I mock things ? - How can I setup (in the test code) the test env so that it can load my plugin ? - How ? I mean what are the best practices, procedures, steps (or whatever ;o) to do it. Shoot, I wish I knew. I'd love to know myself. The former are just a few questions (doubts ?) I have. I could start writing all that from scratch using any testing framework, but I imagine that you already have shortcuts for this (isnt it ? oh ! please tell me so :( ... ). No, sadly, my shortcut is not to write tests because its difficult Wow ! What a tiny shortcut ! :P Well in that case I could take some time to make it simpler, but I'd not want to start from scratch specially knowing that maybe there's something out there being useful ;o) The fact is that some plugins I maintain are getting bigger and I really need to find a way to perform regression tests automatically on them. I prefer to spend some time writing something for that purpose instead of wasting the same time (or more :-/ ) testing every single feature and their interactions and because I don't know if there is a testing framework When I said «I could start writing all that from scratch using any testing framework, » I was thinking about general-purpose testing framews (e.g. unittest, doctest, nose, py.test, dutest ; or maybe others like Mock or twill ) and I haven't had time to write one myself :( Hence me revoicing your concerns Well probably it's time to code together and start doing it ;o) In the end that should be better for everybody : Better plugins for Trac :) -- Regards, Olemis. Blog ES: http://simelo-es.blogspot.com/ Blog EN: http://simelo-en.blogspot.com/ Featured article: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to trac-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: Writing tests for Trac plugins : How ?
On Jul 20, 10:05 am, Olemis Lang ole...@gmail.com wrote: On 7/20/09, Jeff Hammel jham...@openplans.org wrote: On Mon, Jul 20, 2009 at 09:29:22AM -0500, Olemis Lang wrote: On 7/20/09, Jeff Hammel jham...@openplans.org wrote: On Mon, Jul 20, 2009 at 08:47:21AM -0500, Olemis Lang wrote: Well concerning test frameworks (e.g. `unittest`, `doctest` ...) I imagine (I'm sure ?) it's possible. but in the case of Trac plugins there is a peculiar characteristic: - How do I get an env populated with the test data ? - How do I mock things ? - How can I setup (in the test code) the test env so that it can load my plugin ? - How ? I mean what are the best practices, procedures, steps (or whatever ;o) to do it. Shoot, I wish I knew. I'd love to know myself. The former are just a few questions (doubts ?) I have. I could start writing all that from scratch using any testing framework, but I imagine that you already have shortcuts for this (isnt it ? oh ! please tell me so :( ... ). No, sadly, my shortcut is not to write tests because its difficult Wow ! What a tiny shortcut ! :P Well in that case I could take some time to make it simpler, but I'd not want to start from scratch specially knowing that maybe there's something out there being useful ;o) The fact is that some plugins I maintain are getting bigger and I really need to find a way to perform regression tests automatically on them. I prefer to spend some time writing something for that purpose instead of wasting the same time (or more :-/ ) testing every single feature and their interactions and because I don't know if there is a testing framework When I said «I could start writing all that from scratch using any testing framework, » I was thinking about general-purpose testing framews (e.g. unittest, doctest, nose, py.test, dutest ; or maybe others like Mock or twill ) and I haven't had time to write one myself :( Hence me revoicing your concerns Well probably it's time to code together and start doing it ;o) In the end that should be better for everybody : Better plugins for Trac :) -- Regards, Olemis. Blog ES:http://simelo-es.blogspot.com/ Blog EN:http://simelo-en.blogspot.com/ Featured article: trac itself has unit tests, would this not be a good place to start? http://trac.edgewall.org/browser/branches/0.11-stable/TESTING-README Just a thought. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to trac-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: Writing tests for Trac plugins : How ?
Olemis Lang wrote: On 7/20/09, Jeff Hammel jham...@openplans.org wrote: On Mon, Jul 20, 2009 at 09:29:22AM -0500, Olemis Lang wrote: On 7/20/09, Jeff Hammel jham...@openplans.org wrote: On Mon, Jul 20, 2009 at 08:47:21AM -0500, Olemis Lang wrote: Well concerning test frameworks (e.g. `unittest`, `doctest` ...) I imagine (I'm sure ?) it's possible. but in the case of Trac plugins there is a peculiar characteristic: - How do I get an env populated with the test data ? - How do I mock things ? - How can I setup (in the test code) the test env so that it can load my plugin ? - How ? I mean what are the best practices, procedures, steps (or whatever ;o) to do it. Shoot, I wish I knew. I'd love to know myself. The former are just a few questions (doubts ?) I have. I could start writing all that from scratch using any testing framework, but I imagine that you already have shortcuts for this (isnt it ? oh ! please tell me so :( ... ). No, sadly, my shortcut is not to write tests because its difficult Wow ! What a tiny shortcut ! :P Well in that case I could take some time to make it simpler, but I'd not want to start from scratch specially knowing that maybe there's something out there being useful ;o) The fact is that some plugins I maintain are getting bigger and I really need to find a way to perform regression tests automatically on them. I prefer to spend some time writing something for that purpose instead of wasting the same time (or more :-/ ) testing every single feature and their interactions I have some tests in some of my plugins, but not nearly as much as I'd like. Take a look at irclogsplugin parsing_refactor branch --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to trac-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: Writing tests for Trac plugins : How ?
There are numerous plugins on trac-hacks that have unittest based tests. Here are some handy starting points for exploration. http://trac-hacks.org/browser/accountmanagerplugin/trunk/acct_mgr/tests http://trac-hacks.org/browser/announcerplugin/0.11/announcerplugin/tests http://trac-hacks.org/browser/estimationtoolsplugin/trunk/estimationtools/tests http://trac-hacks.org/browser/svnauthzadminplugin/0.11/svnauthz_test http://trac-hacks.org/browser/usermanagerplugin/0.11/tracusermanager/tests http://trac-hacks.org/browser/xmlrpcplugin/trunk/tracrpc/tests And of course Trac itself has a large number of tests as well. http://trac.edgewall.org/browser/trunk/trac/tests http://trac.edgewall.org/browser/trunk/trac/admin/tests http://trac.edgewall.org/browser/trunk/trac/db/tests http://trac.edgewall.org/browser/trunk/trac/mimeview/tests http://trac.edgewall.org/browser/trunk/trac/prefs/tests http://trac.edgewall.org/browser/trunk/trac/ticket/tests http://trac.edgewall.org/browser/trunk/trac/timeline/tests http://trac.edgewall.org/browser/trunk/trac/util/tests http://trac.edgewall.org/browser/trunk/trac/versioncontrol/tests http://trac.edgewall.org/browser/trunk/trac/web/tests http://trac.edgewall.org/browser/trunk/trac/wiki/tests For mocking existing classes (which helps keeps your tests from needing a full environment to run against), take a look at the Mock class in test.py http://trac.edgewall.org/browser/trunk/trac/test.py On Mon, Jul 20, 2009 at 6:47 AM, Olemis Langole...@gmail.com wrote: This time my question is very simple (even if `simple` is relative :P) : - Is it possible to write and run tests for Trac plugins ? - How ? I mean what are the best practices, procedures, steps (or whatever ;o) to do it. - Does any of those integrates with `unittest` ? Thnx in advance ! -- Regards, Olemis. Blog ES: http://simelo-es.blogspot.com/ Blog EN: http://simelo-en.blogspot.com/ Featured article: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to trac-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---