CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Fri, 01 Aug 2025 00:09:32 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20071208114143
location: https://web.archive.org/web/20071208114143/https://wiki.python.org/moin/PyUnit
server-timing: captures_list;dur=0.832081, exclusion.robots;dur=0.028200, exclusion.robots.policy;dur=0.012934, esindex;dur=0.038527, cdx.remote;dur=32.926552, LoadShardBlock;dur=198.217794, PetaboxLoader3.datanode;dur=96.400063, PetaboxLoader3.resolve;dur=47.005951
x-app-server: wwwb-app213
x-ts: 302
x-tr: 295
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app213; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Fri, 01 Aug 2025 00:09:33 GMT
content-type: text/html;charset=utf-8
x-archive-orig-date: Sat, 08 Dec 2007 11:41:43 GMT
x-archive-orig-server: Apache/2.0.54 (Debian GNU/Linux) mod_fastcgi/2.4.2
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sat, 08 Dec 2007 11:41:43 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Fri, 23 Sep 2005 21:40:51 GMT", ; rel="prev memento"; datetime="Wed, 08 Aug 2007 10:36:46 GMT", ; rel="memento"; datetime="Sat, 08 Dec 2007 11:41:43 GMT", ; rel="next memento"; datetime="Sat, 01 Mar 2008 18:22:07 GMT", ; rel="last memento"; datetime="Tue, 21 May 2024 19:10:57 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_1_20071208104348_crawl102-c/52_1_20071208113655_crawl107.arc.gz
server-timing: captures_list;dur=0.484964, exclusion.robots;dur=0.019256, exclusion.robots.policy;dur=0.009155, esindex;dur=0.009282, cdx.remote;dur=8.226372, LoadShardBlock;dur=504.204515, PetaboxLoader3.datanode;dur=213.793121, PetaboxLoader3.resolve;dur=463.928824, load_resource;dur=223.821886
x-app-server: wwwb-app213
x-ts: 200
x-tr: 814
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
PyUnit - PythonInfo Wiki
PyUnit
PyUnit
PyUnit is an easy way to create unit testing programs and UnitTests with Python.
Basic Example
Here's a basic example, making use of standard PyUnit conventions.
1 import unittest
2 from foobarbaz import Foo # code from module you're testing
3
4
5 class SimpleTestCase(unittest.TestCase):
6
7 def setUp(self):
8 """Call before every test case."""
9 self.foo = Foo()
10 self.file = open( "blah", "r" )
11
12 def tearDown(self):
13 """Call after every test case."""
14 self.file.close()
15
16 def testA(self):
17 """Test case A. note that all test method names must begin with 'test.'"""
18 assert foo.bar() == 543, "bar() not calculating values correctly"
19
20 def testB(self):
21 """test case B"""
22 assert foo+foo == 34, "can't add Foo instances"
23
24 def testC(self):
25 """test case C"""
26 assert foo.baz() == "blah", "baz() not returning blah correctly"
27
28
29 class OtherTestCase(unittest.TestCase):
30
31 def setUp(self):
32 blah_blah_blah()
33
34 def tearDown(self):
35 blah_blah_blah()
36
37 def testBlah(self):
38 assert self.blahblah == "blah", "blah isn't blahing blahing correctly"
39
40
41 if __name__ == "__main__":
42 unittest.main() # run all tests
For more details, see the PyUnit manual.
See Also
Dive into Python chapter on unit testing with PyUnit
Discussion
(none yet!)
EditText (last edited 2005-04-02 16:40:46 by LionKimbro)
DeleteCache (cached 2007-12-03 16:59:14)- Login
- Navigation
- Actions
- Your recent pages