diff options
Diffstat (limited to 'tests/mockfedabipkgdiff.in')
-rw-r--r-- | tests/mockfedabipkgdiff.in | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/tests/mockfedabipkgdiff.in b/tests/mockfedabipkgdiff.in index 29a28ad9..1e562666 100644 --- a/tests/mockfedabipkgdiff.in +++ b/tests/mockfedabipkgdiff.in | |||
@@ -39,7 +39,6 @@ variables. | |||
39 | 39 | ||
40 | import os | 40 | import os |
41 | import tempfile | 41 | import tempfile |
42 | import importlib.machinery | ||
43 | import six | 42 | import six |
44 | 43 | ||
45 | try: | 44 | try: |
@@ -69,8 +68,34 @@ def get_download_dir(): | |||
69 | return DOWNLOAD_CACHE_DIR | 68 | return DOWNLOAD_CACHE_DIR |
70 | 69 | ||
71 | 70 | ||
71 | def load_source(name, path): | ||
72 | # Different version of Python want this be done differently. | ||
73 | try: | ||
74 | import importlib.machinery | ||
75 | loader = importlib.machinery.SourceFileLoader(name, path) | ||
76 | import importlib.util | ||
77 | spec = importlib.util.spec_from_loader(name, loader) | ||
78 | module = importlib.util.module_from_spec(spec) | ||
79 | spec.loader.exec_module(module) | ||
80 | import sys.modules | ||
81 | sys.modules[name] = module | ||
82 | return module | ||
83 | except: | ||
84 | pass | ||
85 | try: | ||
86 | import importlib.machinery | ||
87 | loader = importlib.machinery.SourceFileLoader(name, path) | ||
88 | module = loader.load_module() | ||
89 | return module | ||
90 | except: | ||
91 | pass | ||
92 | import imp | ||
93 | module = imp.load_source(name, path) | ||
94 | return module | ||
95 | |||
96 | |||
72 | # Import the fedabipkgdiff program file from the source directory. | 97 | # Import the fedabipkgdiff program file from the source directory. |
73 | fedabipkgdiff_mod = importlib.machinery.SourceFileLoader('fedabipkgdiff', FEDABIPKGDIFF).load_module() | 98 | fedabipkgdiff_mod = load_source('fedabipkgdiff', FEDABIPKGDIFF) |
74 | 99 | ||
75 | 100 | ||
76 | # ----------------- Koji resource storage begins ------------------ | 101 | # ----------------- Koji resource storage begins ------------------ |