Skip to content

Commit

Permalink
Avoid using the deprecated "imp" module.
Browse files Browse the repository at this point in the history
  • Loading branch information
scoder committed May 11, 2023
1 parent e3ef318 commit 07db761
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lxml/html/tests/test_html5parser.py
@@ -1,5 +1,4 @@
import os
import imp
try:
from StringIO import StringIO
except ImportError: # python 3
Expand Down Expand Up @@ -45,7 +44,10 @@ def find_module(self, fullname, path=None):
return None

def load_module(self, fullname):
mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
fake_module = object()
fake_module.__qualname__ = fullname
fake_module.__name__ = fullname.rsplit('.', 1)[-1]
mod = sys.modules.setdefault(fullname, fake_module)
mod.__file__, mod.__loader__, mod.__path__ = "<dummy>", self, []
mod.__dict__.update(self.mocks[fullname])
return mod
Expand Down

0 comments on commit 07db761

Please sign in to comment.