annotate Lib/test/test_frozen.py @ 78069:a8aa77458e12 3.2

Add c_size_t and c_ssize_t to the ctypes summary table.
author Antoine Pitrou <solipsis@pitrou.net>
date Thu, 12 Jul 2012 20:31:50 +0200
parents 2c5736e8a221
children 2dd046be2c88
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20526
1f3c1e831f21 Fix the frozen bytecode for __hello__ (betcha didn't know that existed
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # Test the frozen module defined in frozen.c.
1f3c1e831f21 Fix the frozen bytecode for __hello__ (betcha didn't know that existed
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
47201
9c930a32cebb #2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents: 46664
diff changeset
3 from test.support import captured_stdout, run_unittest
42954
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42056
diff changeset
4 import unittest
59615
b93cfafcdcad Merged revisions 78093 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49651
diff changeset
5 import sys
20526
1f3c1e831f21 Fix the frozen bytecode for __hello__ (betcha didn't know that existed
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
42954
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42056
diff changeset
7 class FrozenTests(unittest.TestCase):
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42056
diff changeset
8 def test_frozen(self):
70152
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
9 with captured_stdout() as stdout:
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
10 try:
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
11 import __hello__
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
12 except ImportError as x:
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
13 self.fail("import __hello__ failed:" + str(x))
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
14 self.assertEqual(__hello__.initialized, True)
70153
2c5736e8a221 (Merge 3.1) Issue #11614: import __hello__ prints "Hello World!". Patch written
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257 70152
diff changeset
15 self.assertEqual(len(dir(__hello__)), 7, dir(__hello__))
70152
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
16 self.assertEqual(stdout.getvalue(), 'Hello world!\n')
20526
1f3c1e831f21 Fix the frozen bytecode for __hello__ (betcha didn't know that existed
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
70152
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
18 with captured_stdout() as stdout:
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
19 try:
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
20 import __phello__
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
21 except ImportError as x:
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
22 self.fail("import __phello__ failed:" + str(x))
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
23 self.assertEqual(__phello__.initialized, True)
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
24 if not "__phello__.spam" in sys.modules:
70153
2c5736e8a221 (Merge 3.1) Issue #11614: import __hello__ prints "Hello World!". Patch written
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257 70152
diff changeset
25 self.assertEqual(len(dir(__phello__)), 8, dir(__phello__))
70152
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
26 else:
70153
2c5736e8a221 (Merge 3.1) Issue #11614: import __hello__ prints "Hello World!". Patch written
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257 70152
diff changeset
27 self.assertEqual(len(dir(__phello__)), 9, dir(__phello__))
70152
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
28 self.assertEqual(__phello__.__path__, [__phello__.__name__])
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
29 self.assertEqual(stdout.getvalue(), 'Hello world!\n')
20526
1f3c1e831f21 Fix the frozen bytecode for __hello__ (betcha didn't know that existed
Guido van Rossum <guido@python.org>
parents:
diff changeset
30
70152
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
31 with captured_stdout() as stdout:
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
32 try:
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
33 import __phello__.spam
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
34 except ImportError as x:
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
35 self.fail("import __phello__.spam failed:" + str(x))
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
36 self.assertEqual(__phello__.spam.initialized, True)
70153
2c5736e8a221 (Merge 3.1) Issue #11614: import __hello__ prints "Hello World!". Patch written
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257 70152
diff changeset
37 self.assertEqual(len(dir(__phello__.spam)), 7)
2c5736e8a221 (Merge 3.1) Issue #11614: import __hello__ prints "Hello World!". Patch written
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257 70152
diff changeset
38 self.assertEqual(len(dir(__phello__)), 9)
70152
44fd95cead7b Issue #11614: import __hello__ prints "Hello World!". Patch written by Andreas
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66340
diff changeset
39 self.assertEqual(stdout.getvalue(), 'Hello world!\n')
42954
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42056
diff changeset
40
43835
a2213060d9dd Fix for refleak tests through regrtest.py -R:: bug #1414
Christian Heimes <christian@cheimes.de>
parents: 43566
diff changeset
41 try:
a2213060d9dd Fix for refleak tests through regrtest.py -R:: bug #1414
Christian Heimes <christian@cheimes.de>
parents: 43566
diff changeset
42 import __phello__.foo
a2213060d9dd Fix for refleak tests through regrtest.py -R:: bug #1414
Christian Heimes <christian@cheimes.de>
parents: 43566
diff changeset
43 except ImportError:
a2213060d9dd Fix for refleak tests through regrtest.py -R:: bug #1414
Christian Heimes <christian@cheimes.de>
parents: 43566
diff changeset
44 pass
a2213060d9dd Fix for refleak tests through regrtest.py -R:: bug #1414
Christian Heimes <christian@cheimes.de>
parents: 43566
diff changeset
45 else:
a2213060d9dd Fix for refleak tests through regrtest.py -R:: bug #1414
Christian Heimes <christian@cheimes.de>
parents: 43566
diff changeset
46 self.fail("import __phello__.foo should have failed")
42954
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42056
diff changeset
47
61259
1f7506f23771 Remove traces of MacOS9 support.
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 60648
diff changeset
48 try:
1f7506f23771 Remove traces of MacOS9 support.
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 60648
diff changeset
49 import __phello__.foo
1f7506f23771 Remove traces of MacOS9 support.
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 60648
diff changeset
50 except ImportError:
1f7506f23771 Remove traces of MacOS9 support.
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 60648
diff changeset
51 pass
1f7506f23771 Remove traces of MacOS9 support.
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 60648
diff changeset
52 else:
1f7506f23771 Remove traces of MacOS9 support.
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 60648
diff changeset
53 self.fail("import __phello__.foo should have failed")
46478
beb7abcd6c01 Merged revisions 62350-62355,62358-62359,62364-62365,62370,62372-62375,62378-62379,62381 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44129
diff changeset
54
beb7abcd6c01 Merged revisions 62350-62355,62358-62359,62364-62365,62370,62372-62375,62378-62379,62381 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44129
diff changeset
55 del sys.modules['__hello__']
beb7abcd6c01 Merged revisions 62350-62355,62358-62359,62364-62365,62370,62372-62375,62378-62379,62381 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44129
diff changeset
56 del sys.modules['__phello__']
beb7abcd6c01 Merged revisions 62350-62355,62358-62359,62364-62365,62370,62372-62375,62378-62379,62381 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44129
diff changeset
57 del sys.modules['__phello__.spam']
beb7abcd6c01 Merged revisions 62350-62355,62358-62359,62364-62365,62370,62372-62375,62378-62379,62381 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44129
diff changeset
58
42954
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42056
diff changeset
59 def test_main():
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42056
diff changeset
60 run_unittest(FrozenTests)
43566
126d2fb735b5 Make it possible to run this test stand-alone.
Guido van Rossum <guido@python.org>
parents: 42954
diff changeset
61
126d2fb735b5 Make it possible to run this test stand-alone.
Guido van Rossum <guido@python.org>
parents: 42954
diff changeset
62 if __name__ == "__main__":
126d2fb735b5 Make it possible to run this test stand-alone.
Guido van Rossum <guido@python.org>
parents: 42954
diff changeset
63 test_main()