Pythoscope: Unit test generation for Python.

August 22nd, 2008 § 4 comments

Recently, there was a thread on the testing-in-python mail­ing list around a pro­posal for a new tool called “Pytho­scope” (dis­cus­sion here).

Pythoscope’s mis­sion — from the web­site is: “To cre­ate an eas­ily cus­tomiz­able and exten­si­ble open source tool that will auto­mat­i­cally, or semi-automatically, gen­er­ate unit tests for legacy sys­tems writ­ten in Python.” To which my gen­eral response is “woop”.

The ini­tial ver­sion was released ear­lier this week. It has a launch­pad site, and a detailed web­site.

This is pretty awe­some. Just on a lark — I decided I’d run it against Python-trunk (what will become 2.6) — unfor­tu­nately, try­ing to gen­er­ate tests for both the mul­ti­pro­cess­ing mod­ule and the thread­ing mod­ule worked not. This is quite prob­a­bly due to the fact I was not run­ning it under the py2.6 binary on my machine, but rather the default python 2.5 — there’s some con­fu­sion about the “with” keyword ;)

I’ll unscrew my envi­ron­ment and get back to you on that one.

Oth­er­wise, I ran it on some per­sonal 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 gen­er­ated all the stubs you could pos­si­bly think of. I am going to keep mon­key­ing with it — and pos­si­bly con­tribut­ing as it will save me a ton of time in the long run.

  • Jean-Paul

    Why does it gen­er­ate two test meth­ods named “test_object_initialization”?

  • Paul­Hilde­brandt

    Cool, the project hasn’t been out that long and peo­ple are already inter­ested. Thanks for blog­ging about it and post­ing a test Jesse. Jean-Paul, it looks like pytho­scope doesn’t han­dle nested classes. I guess that’s okay for a 0.2.1 release. I’ve entered a bug on lunch­pad:
    https://bugs.launchpad.net/pythoscope/+bug/260924
    With a sim­pli­fied test case.

    Paul

  • http://joker.linuxstuff.pl/ Michal Kwiatkowski

    And the bug has been fixed, Pytho­scope now han­dles inner classes cor­rectly. Thanks for the bug report, Paul! :-)

  • http://joker.linuxstuff.pl Micha? Kwiatkowski

    And the bug has been fixed, Pytho­scope now han­dles inner classes cor­rectly. Thanks for the bug report, Paul! :-)

What's this?

You are currently reading Pythoscope: Unit test generation for Python. at jessenoller.com.

meta