aports/testing/py3-snapshottest/importlib.patch

24 lines
730 B
Diff

replace deprecated imp module
diff --git a/snapshottest/module.py b/snapshottest/module.py
index 2f02c83..b0959ed 100644
--- a/snapshottest/module.py
+++ b/snapshottest/module.py
@@ -1,7 +1,7 @@
import codecs
import errno
import os
-import imp
+from importlib.machinery import SourceFileLoader
from collections import defaultdict
import logging
@@ -29,7 +29,7 @@ class SnapshotModule(object):
def load_snapshots(self):
try:
- source = imp.load_source(self.module, self.filepath)
+ source = SourceFileLoader(self.module, self.filepath).load_module()
# except FileNotFoundError: # Python 3
except (IOError, OSError) as err:
if err.errno == errno.ENOENT: