Use builtin compile in doc example

Follow up to #7438
This commit is contained in:
Bruno Oliveira 2020-07-07 18:41:31 -03:00
parent 678c1a0745
commit 9db9f04432
1 changed files with 1 additions and 2 deletions

View File

@ -1,4 +1,3 @@
import _pytest._code
import pytest import pytest
from pytest import raises from pytest import raises
@ -197,7 +196,7 @@ def test_dynamic_compile_shows_nicely():
name = "abc-123" name = "abc-123"
spec = importlib.util.spec_from_loader(name, loader=None) spec = importlib.util.spec_from_loader(name, loader=None)
module = importlib.util.module_from_spec(spec) module = importlib.util.module_from_spec(spec)
code = _pytest._code.compile(src, name, "exec") code = compile(src, name, "exec")
exec(code, module.__dict__) exec(code, module.__dict__)
sys.modules[name] = module sys.modules[name] = module
module.foo() module.foo()