Merged revisions 75264,75268,75293,75318,75391-75392,75436,75478,75971,76003,76058,76140-76141,76231,76380,76428-76429 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75264 | andrew.kuchling | 2009-10-05 17:30:22 -0500 (Mon, 05 Oct 2009) | 1 line
Add various items
........
r75268 | andrew.kuchling | 2009-10-05 17:45:39 -0500 (Mon, 05 Oct 2009) | 1 line
Remove two notes
........
r75293 | kristjan.jonsson | 2009-10-09 09:32:19 -0500 (Fri, 09 Oct 2009) | 2 lines
http://bugs.python.org/issue7029
a non-default timer wasn't actually used by the individual Tests.
........
r75318 | benjamin.peterson | 2009-10-10 16:15:58 -0500 (Sat, 10 Oct 2009) | 1 line
remove script which uses long gone module
........
r75391 | andrew.kuchling | 2009-10-13 10:49:33 -0500 (Tue, 13 Oct 2009) | 1 line
Link to PEP
........
r75392 | andrew.kuchling | 2009-10-13 11:11:49 -0500 (Tue, 13 Oct 2009) | 1 line
Various link, textual, and markup fixes
........
r75436 | benjamin.peterson | 2009-10-15 10:39:15 -0500 (Thu, 15 Oct 2009) | 1 line
don't need to mess up sys.path
........
r75478 | senthil.kumaran | 2009-10-17 20:58:45 -0500 (Sat, 17 Oct 2009) | 3 lines
Fix a typo.
........
r75971 | benjamin.peterson | 2009-10-30 22:56:15 -0500 (Fri, 30 Oct 2009) | 1 line
add some checks for evaluation order with parenthesis #7210
........
r76003 | antoine.pitrou | 2009-10-31 19:30:13 -0500 (Sat, 31 Oct 2009) | 6 lines
Hopefully fix the buildbot problems on test_mailbox, by computing
the maildir toc cache refresh date before actually refreshing the cache.
(see #6896)
........
r76058 | benjamin.peterson | 2009-11-02 10:14:19 -0600 (Mon, 02 Nov 2009) | 1 line
grant list.index() a more informative error message #7252
........
r76140 | nick.coghlan | 2009-11-07 02:13:55 -0600 (Sat, 07 Nov 2009) | 1 line
Add test for runpy.run_module package execution and use something other than logging as the example of a non-executable package
........
r76141 | nick.coghlan | 2009-11-07 02:15:01 -0600 (Sat, 07 Nov 2009) | 1 line
Some minor cleanups to private runpy code and docstrings
........
r76231 | benjamin.peterson | 2009-11-12 17:42:23 -0600 (Thu, 12 Nov 2009) | 1 line
this main is much more useful
........
r76380 | antoine.pitrou | 2009-11-18 14:20:46 -0600 (Wed, 18 Nov 2009) | 3 lines
Mention Giampolo R's new FTP TLS support in the what's new file
........
r76428 | benjamin.peterson | 2009-11-19 20:15:50 -0600 (Thu, 19 Nov 2009) | 1 line
turn goto into do while loop
........
r76429 | benjamin.peterson | 2009-11-19 20:56:43 -0600 (Thu, 19 Nov 2009) | 2 lines
avoid doing an uneeded import in a function
........
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index b861207..4ef4969 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -915,6 +915,14 @@
self.assertEqual((6 / 2 if 1 else 3), 3)
self.assertEqual((6 < 4 if 0 else 2), 2)
+ def test_paren_evaluation(self):
+ self.assertEqual(16 // (4 // 2), 8)
+ self.assertEqual((16 // 4) // 2, 2)
+ self.assertEqual(16 // 4 // 2, 2)
+ self.assertTrue(False is (2 is 3))
+ self.assertFalse((False is 2) is 3)
+ self.assertFalse(False is 2 is 3)
+
def test_main():
run_unittest(TokenTests, GrammarTests)
diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py
index 88e05fe..0542194 100644
--- a/Lib/test/test_runpy.py
+++ b/Lib/test/test_runpy.py
@@ -100,8 +100,8 @@
self.expect_import_error("a.bee")
self.expect_import_error(".howard")
self.expect_import_error("..eaten")
- # Package
- self.expect_import_error("logging")
+ # Package without __main__.py
+ self.expect_import_error("multiprocessing")
def test_library_module(self):
run_module("runpy")
@@ -113,9 +113,9 @@
pkg_file.close()
return pkg_fname
- def _make_pkg(self, source, depth):
+ def _make_pkg(self, source, depth, mod_base="runpy_test"):
pkg_name = "__runpy_pkg__"
- test_fname = "runpy_test.py"
+ test_fname = mod_base+os.extsep+"py"
pkg_dir = sub_dir = tempfile.mkdtemp()
if verbose: print(" Package tree in:", sub_dir)
sys.path.insert(0, pkg_dir)
@@ -130,7 +130,7 @@
mod_file.write(source)
mod_file.close()
if verbose: print(" Created:", mod_fname)
- mod_name = (pkg_name+".")*depth + "runpy_test"
+ mod_name = (pkg_name+".")*depth + mod_base
return pkg_dir, mod_fname, mod_name
def _del_pkg(self, top, depth, mod_name):
@@ -179,6 +179,28 @@
self._del_pkg(pkg_dir, depth, mod_name)
if verbose: print("Module executed successfully")
+ def _check_package(self, depth):
+ pkg_dir, mod_fname, mod_name = (
+ self._make_pkg("x=1\n", depth, "__main__"))
+ pkg_name, _, _ = mod_name.rpartition(".")
+ forget(mod_name)
+ try:
+ if verbose: print("Running from source:", pkg_name)
+ d1 = run_module(pkg_name) # Read from source
+ self.assertTrue("x" in d1)
+ self.assertTrue(d1["x"] == 1)
+ del d1 # Ensure __loader__ entry doesn't keep file open
+ __import__(mod_name)
+ os.remove(mod_fname)
+ if verbose: print("Running from compiled:", pkg_name)
+ d2 = run_module(pkg_name) # Read from bytecode
+ self.assertTrue("x" in d2)
+ self.assertTrue(d2["x"] == 1)
+ del d2 # Ensure __loader__ entry doesn't keep file open
+ finally:
+ self._del_pkg(pkg_dir, depth, pkg_name)
+ if verbose: print("Package executed successfully")
+
def _add_relative_modules(self, base_dir, source, depth):
if depth <= 1:
raise ValueError("Relative module test needs depth > 1")
@@ -240,6 +262,11 @@
if verbose: print("Testing package depth:", depth)
self._check_module(depth)
+ def test_run_package(self):
+ for depth in range(1, 4):
+ if verbose: print("Testing package depth:", depth)
+ self._check_package(depth)
+
def test_explicit_relative_import(self):
for depth in range(2, 5):
if verbose: print("Testing relative imports at depth:", depth)