Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_frozen.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 | 614c84670c63 |
| children |
| 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 |
|
42783
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
3 from test.test_support import captured_stdout, run_unittest |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
4 import unittest |
|
58817
70e115c34f97
Remove unused imports in test modules.
Georg Brandl <georg@python.org>
parents:
46613
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 |
|
42783
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
7 class FrozenTests(unittest.TestCase): |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
8 def test_frozen(self): |
|
20526
1f3c1e831f21
Fix the frozen bytecode for __hello__ (betcha didn't know that existed
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 |
|
42783
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
10 with captured_stdout() as stdout: |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
11 try: |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
12 import __hello__ |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
13 except ImportError, x: |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
14 self.fail("import __hello__ failed:" + str(x)) |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
15 |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
16 try: |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
17 import __phello__ |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
18 except ImportError, x: |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
19 self.fail("import __phello__ failed:" + str(x)) |
|
20526
1f3c1e831f21
Fix the frozen bytecode for __hello__ (betcha didn't know that existed
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 |
|
42783
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
21 try: |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
22 import __phello__.spam |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
23 except ImportError, x: |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
24 self.fail("import __phello__.spam failed:" + str(x)) |
|
20526
1f3c1e831f21
Fix the frozen bytecode for __hello__ (betcha didn't know that existed
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 |
|
61258
f6785bce54b5
In a number of places code still revers
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
58817
diff
changeset
|
26 try: |
|
f6785bce54b5
In a number of places code still revers
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
58817
diff
changeset
|
27 import __phello__.foo |
|
f6785bce54b5
In a number of places code still revers
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
58817
diff
changeset
|
28 except ImportError: |
|
f6785bce54b5
In a number of places code still revers
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
58817
diff
changeset
|
29 pass |
|
f6785bce54b5
In a number of places code still revers
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
58817
diff
changeset
|
30 else: |
|
f6785bce54b5
In a number of places code still revers
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
58817
diff
changeset
|
31 self.fail("import __phello__.foo should have failed") |
|
42783
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
32 |
|
66348
614c84670c63
Merged revisions 86596 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
61258
diff
changeset
|
33 self.assertEqual(stdout.getvalue(), |
|
614c84670c63
Merged revisions 86596 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
61258
diff
changeset
|
34 'Hello world...\nHello world...\nHello world...\n') |
|
42783
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
35 |
|
46474
5c43159f5ad0
Some tests did not pass on repeated calls (regrtest -R::)
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
46242
diff
changeset
|
36 del sys.modules['__hello__'] |
|
5c43159f5ad0
Some tests did not pass on repeated calls (regrtest -R::)
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
46242
diff
changeset
|
37 del sys.modules['__phello__'] |
|
5c43159f5ad0
Some tests did not pass on repeated calls (regrtest -R::)
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
46242
diff
changeset
|
38 del sys.modules['__phello__.spam'] |
|
5c43159f5ad0
Some tests did not pass on repeated calls (regrtest -R::)
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
46242
diff
changeset
|
39 |
|
42783
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
40 |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
41 def test_main(): |
|
f798c366270c
Port test_frozen to unittest.
Georg Brandl <georg@python.org>
parents:
27162
diff
changeset
|
42 run_unittest(FrozenTests) |
|
46242
4c5065ddb9bd
Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents:
42783
diff
changeset
|
43 |
|
4c5065ddb9bd
Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents:
42783
diff
changeset
|
44 |
|
4c5065ddb9bd
Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents:
42783
diff
changeset
|
45 |
|
4c5065ddb9bd
Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
Brett Cannon <bcannon@gmail.com>
parents:
42783
diff
changeset
|
46 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:
42783
diff
changeset
|
47 test_main() |
