diff options
author | Christian Heimes <christian@cheimes.de> | 2012-10-06 15:14:02 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2012-10-06 15:14:02 (GMT) |
commit | d3df2060a60a7ec349ad12f43a0dcb34d7fedcb4 (patch) | |
tree | dfce2ccb9ed3bd11501f8e0056c5042f50d22057 /Lib | |
parent | 6314d164c9ea6fb7ef52c0ccbaa335f4d3fab9cb (diff) | |
parent | 1d0d541259146f4ed33e3a606a74f227fd6d5fa3 (diff) | |
download | cpython-d3df2060a60a7ec349ad12f43a0dcb34d7fedcb4.zip cpython-d3df2060a60a7ec349ad12f43a0dcb34d7fedcb4.tar.gz cpython-d3df2060a60a7ec349ad12f43a0dcb34d7fedcb4.tar.bz2 |
merge
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/lib2to3/btm_utils.py | 6 | ||||
-rw-r--r-- | Lib/lib2to3/pytree.py | 9 | ||||
-rw-r--r-- | Lib/test/test_subprocess.py | 22 | ||||
-rw-r--r-- | Lib/unittest/loader.py | 3 |
4 files changed, 28 insertions, 12 deletions
diff --git a/Lib/lib2to3/btm_utils.py b/Lib/lib2to3/btm_utils.py index 2276dc9..339750e 100644 --- a/Lib/lib2to3/btm_utils.py +++ b/Lib/lib2to3/btm_utils.py @@ -96,8 +96,7 @@ class MinNode(object): def leaves(self): "Generator that returns the leaves of the tree" for child in self.children: - for x in child.leaves(): - yield x + yield from child.leaves() if not self.children: yield self @@ -277,7 +276,6 @@ def rec_test(sequence, test_func): sub-iterables""" for x in sequence: if isinstance(x, (list, tuple)): - for y in rec_test(x, test_func): - yield y + yield from rec_test(x, test_func) else: yield test_func(x) diff --git a/Lib/lib2to3/pytree.py b/Lib/lib2to3/pytree.py index 17cbf0a..c4a1be3 100644 --- a/Lib/lib2to3/pytree.py +++ b/Lib/lib2to3/pytree.py @@ -194,8 +194,7 @@ class Base(object): def leaves(self): for child in self.children: - for x in child.leaves(): - yield x + yield from child.leaves() def depth(self): if self.parent is None: @@ -274,16 +273,14 @@ class Node(Base): def post_order(self): """Return a post-order iterator for the tree.""" for child in self.children: - for node in child.post_order(): - yield node + yield from child.post_order() yield self def pre_order(self): """Return a pre-order iterator for the tree.""" yield self for child in self.children: - for node in child.pre_order(): - yield node + yield from child.pre_order() def _prefix_getter(self): """ diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 6fc6108..5494feb 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -192,6 +192,28 @@ class ProcessTestCase(BaseTestCase): p.wait() self.assertEqual(p.stderr, None) + @unittest.skipIf(mswindows, "path not included in Windows message") + def test_path_in_arg_not_found_message(self): + # Check that the error message displays the path not found when + # args[0] is not found. + self.assertRaisesRegex(FileNotFoundError, "notfound_blahblah", + subprocess.Popen, ["notfound_blahblah"]) + + @unittest.skipIf(mswindows, "path not displayed in Windows message") + def test_path_in_executable_not_found_message(self): + # Check that the error message displays the executable argument (and + # not args[0]) when the executable argument is not found + # (issue #16114). + # We call sys.exit() inside the code to prevent the test runner + # from hanging if the test fails and finds python. + self.assertRaisesRegex(FileNotFoundError, "notfound_blahblah", + subprocess.Popen, [sys.executable, "-c", + "import sys; sys.exit(47)"], + executable="notfound_blahblah") + self.assertRaisesRegex(FileNotFoundError, "exenotfound_blahblah", + subprocess.Popen, ["argnotfound_blahblah"], + executable="exenotfound_blahblah") + # For use in the test_cwd* tests below. def _normalize_cwd(self, cwd): # Normalize an expected cwd (for Tru64 support). diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py index 541884e..a5ac737 100644 --- a/Lib/unittest/loader.py +++ b/Lib/unittest/loader.py @@ -291,8 +291,7 @@ class TestLoader(object): # tests loaded from package file yield tests # recurse into the package - for test in self._find_tests(full_path, pattern): - yield test + yield from self._find_tests(full_path, pattern) else: try: yield load_tests(self, tests, pattern) |