Skip to content

Commit 911ba33

Browse files
committed
restored python test drivers
[SVN r19976]
1 parent 5cd8cce commit 911ba33

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

example/test_getting_started1.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
r'''>>> import getting_started1
2+
>>> print getting_started1.greet()
3+
hello, world
4+
>>> number = 11
5+
>>> print number, '*', number, '=', getting_started1.square(number)
6+
11 * 11 = 121
7+
'''
8+
9+
def run(args = None):
10+
if args is not None:
11+
import sys
12+
sys.argv = args
13+
import doctest, test_getting_started1
14+
return doctest.testmod(test_getting_started1)
15+
16+
if __name__ == '__main__':
17+
import sys
18+
sys.exit(run()[0])

example/test_getting_started2.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
r'''>>> from getting_started2 import *
2+
>>> hi = hello('California')
3+
>>> hi.greet()
4+
'Hello from California'
5+
>>> invite(hi)
6+
'Hello from California! Please come soon!'
7+
>>> hi.invite()
8+
'Hello from California! Please come soon!'
9+
10+
>>> class wordy(hello):
11+
... def greet(self):
12+
... return hello.greet(self) + ', where the weather is fine'
13+
...
14+
>>> hi2 = wordy('Florida')
15+
>>> hi2.greet()
16+
'Hello from Florida, where the weather is fine'
17+
>>> invite(hi2)
18+
'Hello from Florida! Please come soon!'
19+
'''
20+
21+
def run(args = None):
22+
if args is not None:
23+
import sys
24+
sys.argv = args
25+
import doctest, test_getting_started2
26+
return doctest.testmod(test_getting_started2)
27+
28+
if __name__ == '__main__':
29+
import sys
30+
sys.exit(run()[0])
31+

0 commit comments

Comments
 (0)