Skip to content

Commit

Permalink
bpo-42748: test_asdl_parser now uses exec_module instead of load_modu…
Browse files Browse the repository at this point in the history
…le (#23954)
  • Loading branch information
corona10 committed Dec 26, 2020
1 parent ea25180 commit 0b281f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Lib/test/test_asdl_parser.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -26,7 +27,10 @@ def setUpClass(cls):
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')

Expand Down

0 comments on commit 0b281f9

Please sign in to comment.