Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(36637)

Delta Between Two Patch Sets: Lib/test/test_runpy.py

Issue 14285: Traceback wrong on ImportError while executing a package
Left Patch Set: Created 3 years, 9 months ago
Right Patch Set: Created 3 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/test/test_cmd_line_script.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # Test the runpy module 1 # Test the runpy module
2 import unittest 2 import unittest
3 import os 3 import os
4 import os.path 4 import os.path
5 import sys 5 import sys
6 import re 6 import re
7 import tempfile 7 import tempfile
8 import importlib, importlib.machinery, importlib.util 8 import importlib, importlib.machinery, importlib.util
9 import py_compile 9 import py_compile
10 from test.support import ( 10 from test.support import (
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 else: 190 else:
191 self.fail("Expected import error for " + mod_name) 191 self.fail("Expected import error for " + mod_name)
192 192
193 def test_invalid_names(self): 193 def test_invalid_names(self):
194 # Builtin module 194 # Builtin module
195 self.expect_import_error("sys") 195 self.expect_import_error("sys")
196 # Non-existent modules 196 # Non-existent modules
197 self.expect_import_error("sys.imp.eric") 197 self.expect_import_error("sys.imp.eric")
198 self.expect_import_error("os.path.half") 198 self.expect_import_error("os.path.half")
199 self.expect_import_error("a.bee") 199 self.expect_import_error("a.bee")
200 # Relative names not allowed
200 self.expect_import_error(".howard") 201 self.expect_import_error(".howard")
201 self.expect_import_error("..eaten") 202 self.expect_import_error("..eaten")
203 self.expect_import_error(".test_runpy")
204 self.expect_import_error(".unittest")
202 # Package without __main__.py 205 # Package without __main__.py
203 self.expect_import_error("multiprocessing") 206 self.expect_import_error("multiprocessing")
204 207
205 def test_library_module(self): 208 def test_library_module(self):
206 self.assertEqual(run_module("runpy")["__name__"], "runpy") 209 self.assertEqual(run_module("runpy")["__name__"], "runpy")
207 210
208 def _add_pkg_dir(self, pkg_dir, namespace=False): 211 def _add_pkg_dir(self, pkg_dir, namespace=False):
209 os.mkdir(pkg_dir) 212 os.mkdir(pkg_dir)
210 if namespace: 213 if namespace:
211 return None 214 return None
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 f.write(""" 713 f.write("""
711 #coding:latin1 714 #coding:latin1
712 s = "non-ASCII: h\xe9" 715 s = "non-ASCII: h\xe9"
713 """) 716 """)
714 result = run_path(filename) 717 result = run_path(filename)
715 self.assertEqual(result['s'], "non-ASCII: h\xe9") 718 self.assertEqual(result['s'], "non-ASCII: h\xe9")
716 719
717 720
718 if __name__ == "__main__": 721 if __name__ == "__main__":
719 unittest.main() 722 unittest.main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+