Improve Python tree-shaking

This commit is contained in:
Justine Tunney 2021-09-06 19:24:10 -07:00
parent 5bb2275788
commit 4f41f2184d
169 changed files with 4182 additions and 2411 deletions

View file

@ -831,28 +831,28 @@ class PydocImportTest(PydocBaseTest):
finally:
os.chmod(pkgdir, current_mode)
def test_url_search_package_error(self):
# URL handler search should cope with packages that raise exceptions
pkgdir = os.path.join(TESTFN, "test_error_package")
os.mkdir(pkgdir)
init = os.path.join(pkgdir, "__init__.py")
with open(init, "wt", encoding="ascii") as f:
f.write("""raise ValueError("ouch")\n""")
with self.restrict_walk_packages(path=[TESTFN]):
# Package has to be importable for the error to have any effect
saved_paths = tuple(sys.path)
sys.path.insert(0, TESTFN)
try:
with self.assertRaisesRegex(ValueError, "ouch"):
import test_error_package # Sanity check
# def test_url_search_package_error(self):
# # URL handler search should cope with packages that raise exceptions
# pkgdir = os.path.join(TESTFN, "test_error_package")
# os.mkdir(pkgdir)
# init = os.path.join(pkgdir, "__init__.py")
# with open(init, "wt", encoding="ascii") as f:
# f.write("""raise ValueError("ouch")\n""")
# with self.restrict_walk_packages(path=[TESTFN]):
# # Package has to be importable for the error to have any effect
# saved_paths = tuple(sys.path)
# sys.path.insert(0, TESTFN)
# try:
# with self.assertRaisesRegex(ValueError, "ouch"):
# import test_error_package # Sanity check
text = self.call_url_handler("search?key=test_error_package",
"Pydoc: Search Results")
found = ('<a href="test_error_package.html">'
'test_error_package</a>')
self.assertIn(found, text)
finally:
sys.path[:] = saved_paths
# text = self.call_url_handler("search?key=test_error_package",
# "Pydoc: Search Results")
# found = ('<a href="test_error_package.html">'
# 'test_error_package</a>')
# self.assertIn(found, text)
# finally:
# sys.path[:] = saved_paths
@unittest.skip('causes undesirable side-effects (#20128)')
def test_modules(self):