Issue #17177: Stop using imp in a bunch of tests

This commit is contained in:
Brett Cannon 2013-06-15 17:11:25 -04:00
parent 8a2a902f88
commit 9529fbfd36
7 changed files with 17 additions and 15 deletions

View file

@ -3,11 +3,11 @@
Nick Mathewson
"""
import imp
import sys
import os
import shutil
import importlib
import importlib.util
import unittest
from test.support import run_unittest, create_empty_file, verbose
@ -241,7 +241,8 @@ class LongReprTest(unittest.TestCase):
source_path_len += 2 * (len(self.longname) + 1)
# a path separator + `module_name` + ".py"
source_path_len += len(module_name) + 1 + len(".py")
cached_path_len = source_path_len + len(imp.cache_from_source("x.py")) - len("x.py")
cached_path_len = (source_path_len +
len(importlib.util.cache_from_source("x.py")) - len("x.py"))
if os.name == 'nt' and cached_path_len >= 258:
# Under Windows, the max path len is 260 including C's terminating
# NUL character.