annotate Lib/test/test_dl.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents b36cb4602e21
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4724
de01c66f5fa5 Test for the dl module. This only works for SunOS and Solaris.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
1 #! /usr/bin/env python
de01c66f5fa5 Test for the dl module. This only works for SunOS and Solaris.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
2 """Test dlmodule.c
4737
426f87c465a0 Revised strategy for testing recomended by bwarsaw
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4724
diff changeset
3 Roger E. Masse revised strategy by Barry Warsaw
4724
de01c66f5fa5 Test for the dl module. This only works for SunOS and Solaris.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
4 """
58762
ef8f1c2cb51f Add a missing import.
Georg Brandl <georg@python.org>
parents: 52355
diff changeset
5 import unittest
52355
228cfb6e2900 fix incorrect auto-translation of TestSkipped -> unittest.SkipTest
Benjamin Peterson <benjamin@python.org>
parents: 52353
diff changeset
6 from test.test_support import verbose, import_module
46840
b6b2cea5d306 Deprecate the dl module for removal in 3.0.
Brett Cannon <bcannon@gmail.com>
parents: 46242
diff changeset
7 dl = import_module('dl', deprecated=True)
4737
426f87c465a0 Revised strategy for testing recomended by bwarsaw
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4724
diff changeset
8
426f87c465a0 Revised strategy for testing recomended by bwarsaw
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4724
diff changeset
9 sharedlibs = [
5290
d32b8f4d9d30 Try calling getpid() from /usr/lib/libc.so instead of some other
Guido van Rossum <guido@python.org>
parents: 4811
diff changeset
10 ('/usr/lib/libc.so', 'getpid'),
10281
cef2a1345695 1. Print the error message (carefully) when a dl.open() fails in verbose mode.
Guido van Rossum <guido@python.org>
parents: 7747
diff changeset
11 ('/lib/libc.so.6', 'getpid'),
16804
8156879fe60d Patch #404680: disables the nis module and enables the dl module when
Andrew M. Kuchling <amk@amk.ca>
parents: 15966
diff changeset
12 ('/usr/bin/cygwin1.dll', 'getpid'),
37553
3959810bc549 Python on OS X 10.3 and above now uses dlopen() (via dynload_shlib.c)
Anthony Baxter <anthonybaxter@gmail.com>
parents: 24364
diff changeset
13 ('/usr/lib/libc.dylib', 'getpid'),
4737
426f87c465a0 Revised strategy for testing recomended by bwarsaw
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4724
diff changeset
14 ]
4724
de01c66f5fa5 Test for the dl module. This only works for SunOS and Solaris.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
15
46242
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
16 def test_main():
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
17 for s, func in sharedlibs:
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
18 try:
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
19 if verbose:
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
20 print 'trying to open:', s,
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
21 l = dl.open(s)
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
22 except dl.error, err:
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
23 if verbose:
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
24 print 'failed', repr(str(err))
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
25 pass
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
26 else:
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
27 if verbose:
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
28 print 'succeeded...',
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
29 l.call(func)
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
30 l.close()
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
31 if verbose:
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
32 print 'worked!'
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
33 break
4737
426f87c465a0 Revised strategy for testing recomended by bwarsaw
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4724
diff changeset
34 else:
52355
228cfb6e2900 fix incorrect auto-translation of TestSkipped -> unittest.SkipTest
Benjamin Peterson <benjamin@python.org>
parents: 52353
diff changeset
35 raise unittest.SkipTest, 'Could not open any shared libraries'
46242
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
36
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
37
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
38 if __name__ == '__main__':
4c5065ddb9bd Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents: 37553
diff changeset
39 test_main()