O'Reilly logo

Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites by Gigi Sayfan, Kevin Dangoor, Mark Ramm

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 21.1. Nose

Nose is a sophisticated and unobtrusive unit test framework for Python. It automatically discovers your tests (based on simple naming conventions), runs them, and reports the result. You can write simple test functions, unit test-based test cases or doctests. Nose will happily execute them all. Nose also knows how to intercept the standard Python assert, so you don’t need to learn and depend on some Nose-specific mechanism in your test code. Nose is not TurboGears-specific, and you can (and should) use it to test all your Python code. Let’s see Nose in action by testing a factorial function:

def factorial(n, recursive=True): """Computes the factorial of non-negative integers >>> factorial(0) 1 >>> factorial(5) 120 >>> factorial(4, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required