annotate Lib/test/test_binhex.py @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents 11c701038805
children a7be148f7c56
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4969
0f1ae62dd3b8 test script for the binascii C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
1 #! /usr/bin/env python
11392
a14d9614da00 This test really only tests the binhex module.
Guido van Rossum <guido@python.org>
parents: 7747
diff changeset
2 """Test script for the binhex C module
4969
0f1ae62dd3b8 test script for the binascii C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
3
0f1ae62dd3b8 test script for the binascii C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
4 Uses the mechanism of the python binhex module
17921
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
5 Based on an original test by Roger E. Masse.
4969
0f1ae62dd3b8 test script for the binascii C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
6 """
0f1ae62dd3b8 test script for the binascii C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
7 import binhex
17921
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
8 import os
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
9 import unittest
24364
aa0d2d51fbde Get rid of relative imports in all unittests. Now anything that
Barry Warsaw <barry@python.org>
parents: 20013
diff changeset
10 from test import test_support
4969
0f1ae62dd3b8 test script for the binascii C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
11
17921
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
12
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
13 class BinHexTestCase(unittest.TestCase):
4969
0f1ae62dd3b8 test script for the binascii C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
14
17921
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
15 def setUp(self):
24710
11c701038805 Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Guido van Rossum <guido@python.org>
parents: 24364
diff changeset
16 self.fname1 = test_support.TESTFN + "1"
11c701038805 Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Guido van Rossum <guido@python.org>
parents: 24364
diff changeset
17 self.fname2 = test_support.TESTFN + "2"
4969
0f1ae62dd3b8 test script for the binascii C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
18
17921
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
19 def tearDown(self):
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
20 try: os.unlink(self.fname1)
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
21 except OSError: pass
15305
07f24261c6e6 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 13858
diff changeset
22
17921
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
23 try: os.unlink(self.fname2)
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
24 except OSError: pass
4969
0f1ae62dd3b8 test script for the binascii C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
25
17921
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
26 DATA = 'Jack is my hero'
4969
0f1ae62dd3b8 test script for the binascii C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
27
17921
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
28 def test_binhex(self):
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
29 f = open(self.fname1, 'w')
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
30 f.write(self.DATA)
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
31 f.close()
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
32
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
33 binhex.binhex(self.fname1, self.fname2)
4969
0f1ae62dd3b8 test script for the binascii C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
34
17921
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
35 binhex.hexbin(self.fname2, self.fname1)
4969
0f1ae62dd3b8 test script for the binascii C module.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
36
17921
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
37 f = open(self.fname1, 'r')
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
38 finish = f.readline()
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
39 f.close()
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
40
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
41 self.assertEqual(self.DATA, finish)
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
42
a1fcfdcb3479 Convert binhex regression test to PyUnit. We could use a better test
Fred Drake <fdrake@acm.org>
parents: 15966
diff changeset
43
20013
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 17921
diff changeset
44 def test_main():
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 17921
diff changeset
45 test_support.run_unittest(BinHexTestCase)
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 17921
diff changeset
46
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 17921
diff changeset
47
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 17921
diff changeset
48 if __name__ == "__main__":
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 17921
diff changeset
49 test_main()