Pythoscope: Unit test generation for Python.

Recently, there was a thread on the testing-in-python mailing list around a proposal for a new tool called “Pythoscope” (discussion here).

Pythoscope’s mission – from the website is: “To create an easily customizable and extensible open source tool that will automatically, or semi-automatically, generate unit tests for legacy systems written in Python.” To which my general response is “woop“.

The initial version was released earlier this week. It has a launchpad site, and a detailed website.

This is pretty awesome. Just on a lark – I decided I’d run it against Python-trunk (what will become 2.6) – unfortunately, trying to generate tests for both the multiprocessing module and the threading module worked not. This is quite probably due to the fact I was not running it under the py2.6 binary on my machine, but rather the default python 2.5 – there’s some confusion about the “with” keyword ;)

I’ll unscrew my environment and get back to you on that one.

Otherwise, I ran it on some personal code, and it came up with a pretty decent series of test stubs. Then I decided to run it on svnmerge.py:

?View Code PYTHON
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class TestGetRepoRoot(unittest.TestCase):
    def test_get_repo_root(self):
        assert False # TODO: implement your test here
 
class TestTargetToPathid(unittest.TestCase):
    def test_target_to_pathid(self):
        assert False # TODO: implement your test here
 
class TestSvnLogParser(unittest.TestCase):
    def test_object_initialization(self):
        assert False # TODO: implement your test here
 
    def test_object_initialization(self):
        assert False # TODO: implement your test here
 
    def test_revision(self):
        assert False # TODO: implement your test here
 
    def test_author(self):
        assert False # TODO: implement your test here
 
    def test_paths(self):
        assert False # TODO: implement your test here

Pretty neat – it generated all the stubs you could possibly think of. I am going to keep monkeying with it – and possibly contributing as it will save me a ton of time in the long run.

  • PaulHildebrandt
    Cool, the project hasn't been out that long and people are already interested. Thanks for blogging about it and posting a test Jesse. Jean-Paul, it looks like pythoscope doesn't handle nested classes. I guess that's okay for a 0.2.1 release. I've entered a bug on lunchpad:
    https://bugs.launchpad.net/pythoscope/+bug/260924
    With a simplified test case.

    Paul
  • And the bug has been fixed, Pythoscope now handles inner classes correctly. Thanks for the bug report, Paul! :-)
  • Jean-Paul
    Why does it generate two test methods named "test_object_initialization"?
blog comments powered by Disqus