Test Driven Developer
You got a TEST for that?
Home
|
Syndication
|
Sign In
Tuesday, October 07, 2008
More Tips for Unit Testing in Iron Python
Do you ever wonder why there is an extra "False" printed at the end of each run for unit tests?
C:\Code\sample>ipy UnitTests.py
.....
----------------------------------------------------------------------
Ran 5 tests in 0.395s
OK
False
It looks like there is an exit statement buried inside the unit test framework. We can eliminate the problem pretty easily with the addition of a try/except around the unit test execution. Here is the code to put at the end of your unit test script:
if
__name__
==
'
__main__
':
try
:
unittest.main
()
except
SystemExit:
pass
This catches and eats the SystemExit exception, and runs without printing the "False" at the end of the execution:
C:\Code\sample>ipy UnitTests.py
.....
----------------------------------------------------------------------
Ran 5 tests in 0.387s
OK
cheers!
Python
|
Testing
|
Unit Tests
Tuesday, October 07, 2008 8:09:49 AM (Pacific Standard Time, UTC-08:00)
Comments [0]
|
Comments are closed.
© Copyright 2009, John E. Boal
Calendar
<
January 2009
>
Sun
Mon
Tue
Wed
Thu
Fri
Sat
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
Total Posts: 32
This Year: 0
This Month: 0
This Week: 0
Comments: 19
Archives
December, 2008 (2)
November, 2008 (2)
October, 2008 (2)
September, 2008 (4)
August, 2008 (3)
July, 2008 (5)
June, 2008 (4)
May, 2008 (1)
April, 2008 (2)
March, 2008 (4)
February, 2008 (2)
January, 2008 (1)
On this page
categories
ABN
Acceptance Criteria
ATDD
Automation
C#
Mocks
MSTest
Python
Refactoring
Selenium
SQL
TDD
Testing
Tools
Unit Tests
WatiN
Links
Home
Test Driven Development, Defined (Wikipedia)
Test Driven Design
Test-Driven.com - Agile development tools
NUnit
Book: Test-Driven Development in Microsoft .NET
CodeProject - Advanced Unit Testing: Unit Test Patterns
John Boal's Personal Blog
John Boal's Agile Development Blog
Blogroll
OPML
Lazy Coder
Scott Koon's Blog
#2782
Ade Miller's Tech Blog
Agile Development
Mitch Lacey's Agile Development Blog
Espresso Fueled Agile Development
Mike Puleio's Blog
Geek Noise
Noise de Peter Provost
Sneal's Blog
Shawn Neal's Blog
Search
About
© Copyright 2009, John E. Boal
Sign In