annotate Lib/test/test_pkg.py @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents 07229c6104b1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6247
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # Test packages (dotted-name import)
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
3 import sys
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
4 import os
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
5 import tempfile
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
6 import textwrap
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
7 import unittest
47201
9c930a32cebb #2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents: 46478
diff changeset
8 from test import support
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
9
6247
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 # Helpers to create and destroy hierarchies.
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 def cleanout(root):
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 names = os.listdir(root)
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 for name in names:
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6539
diff changeset
16 fullname = os.path.join(root, name)
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6539
diff changeset
17 if os.path.isdir(fullname) and not os.path.islink(fullname):
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6539
diff changeset
18 cleanout(fullname)
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6539
diff changeset
19 else:
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6539
diff changeset
20 os.remove(fullname)
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
21 os.rmdir(root)
6247
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
14342
d41c41371dc1 Applying patch #100994 to allow JPython to use more of the standard
Barry Warsaw <barry@python.org>
parents: 14038
diff changeset
23 def fixdir(lst):
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
24 if "__builtins__" in lst:
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
25 lst.remove("__builtins__")
77013
edb9ce3a6c2e Issue #9260: A finer-grained import lock.
Antoine Pitrou <solipsis@pitrou.net>
parents: 76303
diff changeset
26 if "__initializing__" in lst:
edb9ce3a6c2e Issue #9260: A finer-grained import lock.
Antoine Pitrou <solipsis@pitrou.net>
parents: 76303
diff changeset
27 lst.remove("__initializing__")
14342
d41c41371dc1 Applying patch #100994 to allow JPython to use more of the standard
Barry Warsaw <barry@python.org>
parents: 14038
diff changeset
28 return lst
d41c41371dc1 Applying patch #100994 to allow JPython to use more of the standard
Barry Warsaw <barry@python.org>
parents: 14038
diff changeset
29
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
30
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
31 # XXX Things to test
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
32 #
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
33 # import package without __init__
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
34 # import package with __init__
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
35 # __init__ importing submodule
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
36 # __init__ importing global module
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
37 # __init__ defining variables
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
38 # submodule importing other submodule
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
39 # submodule importing global module
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
40 # submodule import submodule via global name
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
41 # from package import submodule
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
42 # from package import subpackage
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
43 # from package import variable (defined in __init__)
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
44 # from package import * (defined in __init__)
6247
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
45
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
46
43836
1d6db9dd3e77 Another fix for #1414
Christian Heimes <christian@cheimes.de>
parents: 42954
diff changeset
47 class TestPkg(unittest.TestCase):
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
48
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
49 def setUp(self):
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
50 self.root = None
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: 45471
diff changeset
51 self.pkgname = None
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
52 self.syspath = list(sys.path)
57215
357e39700489 Merged revisions 76240 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 55593
diff changeset
53 self.modules_before = support.modules_setup()
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
54
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
55 def tearDown(self):
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
56 sys.path[:] = self.syspath
57215
357e39700489 Merged revisions 76240 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 55593
diff changeset
57 support.modules_cleanup(*self.modules_before)
59091
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
58 if self.root: # Only clean if the test was actually run
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
59 cleanout(self.root)
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
60
68585
bf94b6a73fc8 #11565: Fix several typos. Patch by Piotr Kasprzyk.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 57215
diff changeset
61 # delete all modules concerning the tested hierarchy
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: 45471
diff changeset
62 if self.pkgname:
beb7abcd6c01 Merged revisions 62350-62355,62358-62359,62364-62365,62370,62372-62375,62378-62379,62381 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45471
diff changeset
63 modules = [name for name in sys.modules
beb7abcd6c01 Merged revisions 62350-62355,62358-62359,62364-62365,62370,62372-62375,62378-62379,62381 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45471
diff changeset
64 if self.pkgname in name.split('.')]
beb7abcd6c01 Merged revisions 62350-62355,62358-62359,62364-62365,62370,62372-62375,62378-62379,62381 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45471
diff changeset
65 for name in modules:
beb7abcd6c01 Merged revisions 62350-62355,62358-62359,62364-62365,62370,62372-62375,62378-62379,62381 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45471
diff changeset
66 del sys.modules[name]
beb7abcd6c01 Merged revisions 62350-62355,62358-62359,62364-62365,62370,62372-62375,62378-62379,62381 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45471
diff changeset
67
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
68 def run_code(self, code):
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
69 exec(textwrap.dedent(code), globals(), {"self": self})
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
70
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
71 def mkhier(self, descr):
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
72 root = tempfile.mkdtemp()
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6539
diff changeset
73 sys.path.insert(0, root)
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
74 if not os.path.isdir(root):
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
75 os.mkdir(root)
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
76 for name, contents in descr:
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
77 comps = name.split()
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
78 fullname = root
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
79 for c in comps:
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
80 fullname = os.path.join(fullname, c)
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
81 if contents is None:
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
82 os.mkdir(fullname)
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
83 else:
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
84 f = open(fullname, "w")
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
85 f.write(contents)
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
86 if contents and contents[-1] != '\n':
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
87 f.write('\n')
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
88 f.close()
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
89 self.root = root
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: 45471
diff changeset
90 # package name is the name of the first item
beb7abcd6c01 Merged revisions 62350-62355,62358-62359,62364-62365,62370,62372-62375,62378-62379,62381 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45471
diff changeset
91 self.pkgname = descr[0][0]
6247
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
92
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
93 def test_1(self):
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
94 hier = [("t1", None), ("t1 __init__.py", "")]
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
95 self.mkhier(hier)
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
96 import t1
15305
07f24261c6e6 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 14342
diff changeset
97
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
98 def test_2(self):
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
99 hier = [
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
100 ("t2", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
101 ("t2 __init__.py", "'doc for t2'"),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
102 ("t2 sub", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
103 ("t2 sub __init__.py", ""),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
104 ("t2 sub subsub", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
105 ("t2 sub subsub __init__.py", "spam = 1"),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
106 ]
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
107 self.mkhier(hier)
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
108
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
109 import t2.sub
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
110 import t2.sub.subsub
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
111 self.assertEqual(t2.__name__, "t2")
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
112 self.assertEqual(t2.sub.__name__, "t2.sub")
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
113 self.assertEqual(t2.sub.subsub.__name__, "t2.sub.subsub")
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
114
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
115 # This exec crap is needed because Py3k forbids 'import *' outside
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
116 # of module-scope and __import__() is insufficient for what we need.
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
117 s = """
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
118 import t2
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
119 from t2 import *
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
120 self.assertEqual(dir(), ['self', 'sub', 't2'])
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
121 """
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
122 self.run_code(s)
15305
07f24261c6e6 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 14342
diff changeset
123
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
124 from t2 import sub
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
125 from t2.sub import subsub
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
126 from t2.sub.subsub import spam
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
127 self.assertEqual(sub.__name__, "t2.sub")
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
128 self.assertEqual(subsub.__name__, "t2.sub.subsub")
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
129 self.assertEqual(sub.subsub.__name__, "t2.sub.subsub")
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
130 for name in ['spam', 'sub', 'subsub', 't2']:
55593
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47201
diff changeset
131 self.assertTrue(locals()["name"], "Failed to import %s" % name)
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
132
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
133 import t2.sub
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
134 import t2.sub.subsub
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
135 self.assertEqual(t2.__name__, "t2")
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
136 self.assertEqual(t2.sub.__name__, "t2.sub")
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
137 self.assertEqual(t2.sub.subsub.__name__, "t2.sub.subsub")
15305
07f24261c6e6 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 14342
diff changeset
138
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
139 s = """
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
140 from t2 import *
55593
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47201
diff changeset
141 self.assertTrue(dir(), ['self', 'sub'])
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
142 """
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
143 self.run_code(s)
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
144
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
145 def test_3(self):
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
146 hier = [
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
147 ("t3", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
148 ("t3 __init__.py", ""),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
149 ("t3 sub", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
150 ("t3 sub __init__.py", ""),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
151 ("t3 sub subsub", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
152 ("t3 sub subsub __init__.py", "spam = 1"),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
153 ]
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
154 self.mkhier(hier)
6247
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
155
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
156 import t3.sub.subsub
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
157 self.assertEqual(t3.__name__, "t3")
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
158 self.assertEqual(t3.sub.__name__, "t3.sub")
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
159 self.assertEqual(t3.sub.subsub.__name__, "t3.sub.subsub")
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
160
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
161 def test_4(self):
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
162 hier = [
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
163 ("t4.py", "raise RuntimeError('Shouldnt load t4.py')"),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
164 ("t4", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
165 ("t4 __init__.py", ""),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
166 ("t4 sub.py", "raise RuntimeError('Shouldnt load sub.py')"),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
167 ("t4 sub", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
168 ("t4 sub __init__.py", ""),
42954
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42790
diff changeset
169 ("t4 sub subsub.py",
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42790
diff changeset
170 "raise RuntimeError('Shouldnt load subsub.py')"),
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
171 ("t4 sub subsub", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
172 ("t4 sub subsub __init__.py", "spam = 1"),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
173 ]
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
174 self.mkhier(hier)
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
175
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
176 s = """
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
177 from t4.sub.subsub import *
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
178 self.assertEqual(spam, 1)
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
179 """
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
180 self.run_code(s)
6247
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
181
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
182 def test_5(self):
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
183 hier = [
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
184 ("t5", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
185 ("t5 __init__.py", "import t5.foo"),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
186 ("t5 string.py", "spam = 1"),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
187 ("t5 foo.py",
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
188 "from . import string; assert string.spam == 1"),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
189 ]
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
190 self.mkhier(hier)
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
191
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
192 import t5
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
193 s = """
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
194 from t5 import *
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
195 self.assertEqual(dir(), ['foo', 'self', 'string', 't5'])
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
196 """
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
197 self.run_code(s)
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
198
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
199 import t5
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
200 self.assertEqual(fixdir(dir(t5)),
76303
2dd046be2c88 Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents: 68586
diff changeset
201 ['__cached__', '__doc__', '__file__', '__loader__',
87347
07229c6104b1 Implement PEP 451 (ModuleSpec).
Eric Snow <ericsnowcurrently@gmail.com>
parents: 77013
diff changeset
202 '__name__', '__package__', '__path__', '__spec__',
07229c6104b1 Implement PEP 451 (ModuleSpec).
Eric Snow <ericsnowcurrently@gmail.com>
parents: 77013
diff changeset
203 'foo', 'string', 't5'])
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
204 self.assertEqual(fixdir(dir(t5.foo)),
76303
2dd046be2c88 Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents: 68586
diff changeset
205 ['__cached__', '__doc__', '__file__', '__loader__',
87347
07229c6104b1 Implement PEP 451 (ModuleSpec).
Eric Snow <ericsnowcurrently@gmail.com>
parents: 77013
diff changeset
206 '__name__', '__package__', '__spec__', 'string'])
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
207 self.assertEqual(fixdir(dir(t5.string)),
76303
2dd046be2c88 Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents: 68586
diff changeset
208 ['__cached__', '__doc__', '__file__', '__loader__',
87347
07229c6104b1 Implement PEP 451 (ModuleSpec).
Eric Snow <ericsnowcurrently@gmail.com>
parents: 77013
diff changeset
209 '__name__', '__package__', '__spec__', 'spam'])
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
210
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
211 def test_6(self):
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
212 hier = [
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
213 ("t6", None),
42954
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42790
diff changeset
214 ("t6 __init__.py",
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42790
diff changeset
215 "__all__ = ['spam', 'ham', 'eggs']"),
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
216 ("t6 spam.py", ""),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
217 ("t6 ham.py", ""),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
218 ("t6 eggs.py", ""),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
219 ]
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
220 self.mkhier(hier)
15305
07f24261c6e6 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 14342
diff changeset
221
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
222 import t6
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
223 self.assertEqual(fixdir(dir(t6)),
60648
7b69e630d237 PEP 3147
Barry Warsaw <barry@python.org>
parents: 59091
diff changeset
224 ['__all__', '__cached__', '__doc__', '__file__',
87347
07229c6104b1 Implement PEP 451 (ModuleSpec).
Eric Snow <ericsnowcurrently@gmail.com>
parents: 77013
diff changeset
225 '__loader__', '__name__', '__package__', '__path__',
07229c6104b1 Implement PEP 451 (ModuleSpec).
Eric Snow <ericsnowcurrently@gmail.com>
parents: 77013
diff changeset
226 '__spec__'])
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
227 s = """
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
228 import t6
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
229 from t6 import *
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
230 self.assertEqual(fixdir(dir(t6)),
60648
7b69e630d237 PEP 3147
Barry Warsaw <barry@python.org>
parents: 59091
diff changeset
231 ['__all__', '__cached__', '__doc__', '__file__',
76303
2dd046be2c88 Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents: 68586
diff changeset
232 '__loader__', '__name__', '__package__',
87347
07229c6104b1 Implement PEP 451 (ModuleSpec).
Eric Snow <ericsnowcurrently@gmail.com>
parents: 77013
diff changeset
233 '__path__', '__spec__', 'eggs', 'ham', 'spam'])
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
234 self.assertEqual(dir(), ['eggs', 'ham', 'self', 'spam', 't6'])
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
235 """
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
236 self.run_code(s)
6284
daa62c2264b5 Added test for __all__.
Guido van Rossum <guido@python.org>
parents: 6255
diff changeset
237
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
238 def test_7(self):
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
239 hier = [
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
240 ("t7.py", ""),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
241 ("t7", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
242 ("t7 __init__.py", ""),
42954
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42790
diff changeset
243 ("t7 sub.py",
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42790
diff changeset
244 "raise RuntimeError('Shouldnt load sub.py')"),
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
245 ("t7 sub", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
246 ("t7 sub __init__.py", ""),
42954
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42790
diff changeset
247 ("t7 sub .py",
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
248 "raise RuntimeError('Shouldnt load subsub.py')"),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
249 ("t7 sub subsub", None),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
250 ("t7 sub subsub __init__.py",
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
251 "spam = 1"),
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
252 ]
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
253 self.mkhier(hier)
6247
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
254
1496444e8c8b Test set for package import.
Guido van Rossum <guido@python.org>
parents:
diff changeset
255
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
256 t7, sub, subsub = None, None, None
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
257 import t7 as tas
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
258 self.assertEqual(fixdir(dir(tas)),
76303
2dd046be2c88 Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents: 68586
diff changeset
259 ['__cached__', '__doc__', '__file__', '__loader__',
87347
07229c6104b1 Implement PEP 451 (ModuleSpec).
Eric Snow <ericsnowcurrently@gmail.com>
parents: 77013
diff changeset
260 '__name__', '__package__', '__path__', '__spec__'])
55593
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47201
diff changeset
261 self.assertFalse(t7)
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
262 from t7 import sub as subpar
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
263 self.assertEqual(fixdir(dir(subpar)),
76303
2dd046be2c88 Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents: 68586
diff changeset
264 ['__cached__', '__doc__', '__file__', '__loader__',
87347
07229c6104b1 Implement PEP 451 (ModuleSpec).
Eric Snow <ericsnowcurrently@gmail.com>
parents: 77013
diff changeset
265 '__name__', '__package__', '__path__', '__spec__'])
55593
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47201
diff changeset
266 self.assertFalse(t7)
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47201
diff changeset
267 self.assertFalse(sub)
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
268 from t7.sub import subsub as subsubsub
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
269 self.assertEqual(fixdir(dir(subsubsub)),
76303
2dd046be2c88 Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents: 68586
diff changeset
270 ['__cached__', '__doc__', '__file__', '__loader__',
87347
07229c6104b1 Implement PEP 451 (ModuleSpec).
Eric Snow <ericsnowcurrently@gmail.com>
parents: 77013
diff changeset
271 '__name__', '__package__', '__path__', '__spec__',
07229c6104b1 Implement PEP 451 (ModuleSpec).
Eric Snow <ericsnowcurrently@gmail.com>
parents: 77013
diff changeset
272 'spam'])
55593
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47201
diff changeset
273 self.assertFalse(t7)
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47201
diff changeset
274 self.assertFalse(sub)
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47201
diff changeset
275 self.assertFalse(subsub)
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
276 from t7.sub.subsub import spam as ham
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
277 self.assertEqual(ham, 1)
55593
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47201
diff changeset
278 self.assertFalse(t7)
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47201
diff changeset
279 self.assertFalse(sub)
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47201
diff changeset
280 self.assertFalse(subsub)
6255
f446e08ac302 Fix details in the test:
Guido van Rossum <guido@python.org>
parents: 6251
diff changeset
281
59091
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
282 @unittest.skipIf(sys.flags.optimize >= 2,
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
283 "Docstrings are omitted with -O2 and above")
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
284 def test_8(self):
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
285 hier = [
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
286 ("t8", None),
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
287 ("t8 __init__"+os.extsep+"py", "'doc for t8'"),
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
288 ]
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
289 self.mkhier(hier)
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
290
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
291 import t8
8d3ff2fbbe4b Merged revisions 78351 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 57215
diff changeset
292 self.assertEqual(t8.__doc__, "doc for t8")
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
293
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
294 def test_main():
47201
9c930a32cebb #2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents: 46478
diff changeset
295 support.run_unittest(__name__)
8375
242b3c9c5bec Test that "import sys.imp" fails as it should.
Guido van Rossum <guido@python.org>
parents: 7747
diff changeset
296
42790
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
297
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
298 if __name__ == "__main__":
6124b2ef6512 Convert test_pkg to use unittest.
Collin Winter <collinw@gmail.com>
parents: 42622
diff changeset
299 test_main()