Setting up agile development with Python/Komodo (part 1)
This will be a series of tutorials showing how to set up for agile development in the Komodo Edit environment. By the end of the series, we will have our Komodo project set up with the following:
- Automated unit testing via hot key
- Automated build cycle, that:
The tutorials assume use of Komodo Edit on Windows, but some of the components (nose/epydoc/Mercurial) could be used on any platform. The final code after completing the tutorial can be found here.
In part 1, we're going to set up our project to perform automated unit testing, add another convenience command ("run current script"), and get our automated build cycle started, with just the unit tests for now.
OK, let's get started. I'll assume you've already installed Komodo Edit and nose. Make sure that your PATH environment variable has "c:\python2x\scripts\" in it so you can run nosetests from the command line.
First, create a new command in the toolbox to automatically run your unit tests. Set it up as follows:

Also give it an appropriate key binding. I prefer F7 (yeah, I'm a fallback from Visual Studio).
Now we'll create a little project to test this out. Create a project in a new folder, and add a file named test_module.py:

Here's the file code:
"""
Unit test the module
"""
def test_module():
assert False
Run your unit tests using F7 (or whatever shortcut you picked), and make sure you get a failed test. Next, change the code as follows:
"""
Unit test the module
"""
from nose.tools import raises
@raises(AssertionError)
def test_module():
assert False
Run it, and make sure you get 1 test, passed.
———————————————————————-
Ran 1 test in 0.000s
OK
OK, we're in business! Now let's just get our automated build script started. Add another file to your project, build.py, as follows:
"""
Automated build for project
"""
import os
import subprocess
def run_command(command):
"""Runs the command line, asserts success"""
proc = subprocess.Popen(command,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
for line in proc.stdout:
print line.strip()
for line in proc.stderr:
print line.strip()
assert not proc.returncode
def build():
"""Performs the automated build"""
curr_dir = os.path.dirname(__file__)
os.chdir(curr_dir)
# Unit tests
run_command('nosetests -w "%s"' % curr_dir)
if __name__ == "__main__":
build()
Create another command in the toolbox, this time to run the current file. Set the command to python "%F" (I like setting the key binding to F5…). Run it, and make sure it works. Note that our build process is set to bail if any link in the chain fails (by asserting the return code).
This concludes the first part of the series. In the next part, we'll set up the automatic build of our executable and setup file.

FYI, you can also use the kNose extension (http://mysite.verizon.net/bcorfman/knose.html) for more integrated unit testing within Komodo.
@Brandon Corfman
Thanks for the mention of kNose. I had tried it out but failed to get it working on my main machine (Windows). It’s been some time since then, so I’ll give it another try.
Please let me know if you have any issues with the current version of kNose. I’ll be glad to help you work through them.
bcorfman (at) verizon (dot) net