summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na@python.org>2020-12-26 13:25:21 (GMT)
committerGitHub <noreply@github.com>2020-12-26 13:25:21 (GMT)
commit0b281f94b9e5f117d774a1e4e834e797b2b21438 (patch)
tree038d41daafb6a93180b6c5a2bfeeae98d42af6c0
parentea251806b8dffff11b30d2182af1e589caf88acf (diff)
downloadcpython-0b281f94b9e5f117d774a1e4e834e797b2b21438.zip
cpython-0b281f94b9e5f117d774a1e4e834e797b2b21438.tar.gz
cpython-0b281f94b9e5f117d774a1e4e834e797b2b21438.tar.bz2
bpo-42748: test_asdl_parser now uses exec_module instead of load_module (#23954)
-rw-r--r--Lib/test/test_asdl_parser.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_asdl_parser.py b/Lib/test/test_asdl_parser.py
index 2c14817..d2c2b51 100644
--- a/Lib/test/test_asdl_parser.py
+++ b/Lib/test/test_asdl_parser.py
@@ -1,6 +1,7 @@
"""Tests for the asdl parser in Parser/asdl.py"""
import importlib.machinery
+import importlib.util
import os
from os.path import dirname
import sys
@@ -26,7 +27,10 @@ class TestAsdlParser(unittest.TestCase):
sys.path.insert(0, parser_dir)
loader = importlib.machinery.SourceFileLoader(
'asdl', os.path.join(parser_dir, 'asdl.py'))
- cls.asdl = loader.load_module()
+ spec = importlib.util.spec_from_loader('asdl', loader)
+ module = importlib.util.module_from_spec(spec)
+ loader.exec_module(module)
+ cls.asdl = module
cls.mod = cls.asdl.parse(os.path.join(parser_dir, 'Python.asdl'))
cls.assertTrue(cls.asdl.check(cls.mod), 'Module validation failed')