diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2023-05-11 10:29:02 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2023-05-11 10:29:02 +0200 |
commit | 07db761f9f027d1814a43686cda6fca26e37a931 (patch) | |
tree | d9c3b9e26e644fbe01dcad8fbd1d40db7adf108c | |
parent | e3ef31814f822f86e831d6c66020b3421462fc32 (diff) | |
download | python-lxml-07db761f9f027d1814a43686cda6fca26e37a931.tar.gz |
Avoid using the deprecated "imp" module.
Closes https://bugs.launchpad.net/lxml/+bug/2018137
-rw-r--r-- | src/lxml/html/tests/test_html5parser.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lxml/html/tests/test_html5parser.py b/src/lxml/html/tests/test_html5parser.py index 56afe98b..bcf7f1b1 100644 --- a/src/lxml/html/tests/test_html5parser.py +++ b/src/lxml/html/tests/test_html5parser.py @@ -1,5 +1,4 @@ import os -import imp try: from StringIO import StringIO except ImportError: # python 3 @@ -45,7 +44,10 @@ except ImportError: 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 |