summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 15:11:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 15:11:27 +0000
commitf3bcaf9f88aad2c423ebcd61121562f9834187d4 (patch)
treef22238c29b57707b645a350940e3e9bdf3ce1f5d /testing
parentAdding debian version 115.7.0esr-1~deb12u1. (diff)
downloadfirefox-esr-f3bcaf9f88aad2c423ebcd61121562f9834187d4.tar.xz
firefox-esr-f3bcaf9f88aad2c423ebcd61121562f9834187d4.zip
Merging upstream version 115.8.0esr.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing')
-rw-r--r--testing/marionette/harness/marionette_harness/marionette_test/testcases.py22
-rw-r--r--testing/mochitest/mach_commands.py22
-rw-r--r--testing/mozbase/mozfile/mozfile/mozfile.py14
-rw-r--r--testing/mozbase/mozprofile/mozprofile/prefs.py14
-rwxr-xr-xtesting/mozharness/scripts/desktop_unittest.py4
-rw-r--r--testing/raptor/mach_commands.py4
-rw-r--r--testing/web-platform/manifestupdate.py6
-rw-r--r--testing/web-platform/tests/service-workers/service-worker/resources/scope1/redirect.py6
-rw-r--r--testing/web-platform/tests/service-workers/service-worker/resources/scope2/worker_interception_redirect_webworker.py6
-rw-r--r--testing/web-platform/tests/service-workers/service-worker/resources/subdir/worker_interception_redirect_webworker.py6
-rw-r--r--testing/web-platform/tests/tools/runner/update_manifest.py6
-rw-r--r--testing/web-platform/tests/tools/wpt/utils.py15
-rw-r--r--testing/web-platform/tests/tools/wptrunner/wptrunner/stability.py8
-rw-r--r--testing/web-platform/tests/xhr/resources/auth1/auth.py5
-rw-r--r--testing/web-platform/tests/xhr/resources/auth10/auth.py6
-rw-r--r--testing/web-platform/tests/xhr/resources/auth11/auth.py5
-rw-r--r--testing/web-platform/tests/xhr/resources/auth2/auth.py6
-rw-r--r--testing/web-platform/tests/xhr/resources/auth2/corsenabled.py5
-rw-r--r--testing/web-platform/tests/xhr/resources/auth3/auth.py5
-rw-r--r--testing/web-platform/tests/xhr/resources/auth4/auth.py5
-rw-r--r--testing/web-platform/tests/xhr/resources/auth7/corsenabled.py5
-rw-r--r--testing/web-platform/tests/xhr/resources/auth8/corsenabled-no-authorize.py5
-rw-r--r--testing/web-platform/tests/xhr/resources/auth9/auth.py5
-rw-r--r--testing/web-platform/update/__init__.py4
24 files changed, 116 insertions, 73 deletions
diff --git a/testing/marionette/harness/marionette_harness/marionette_test/testcases.py b/testing/marionette/harness/marionette_harness/marionette_test/testcases.py
index 32c36967bb..84a6e09665 100644
--- a/testing/marionette/harness/marionette_harness/marionette_test/testcases.py
+++ b/testing/marionette/harness/marionette_harness/marionette_test/testcases.py
@@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-import imp
+
import os
import re
import sys
@@ -14,6 +14,7 @@ from unittest.case import SkipTest
import six
from marionette_driver.errors import TimeoutException, UnresponsiveInstanceException
+from mozfile import load_source
from mozlog import get_default_logger
@@ -365,21 +366,20 @@ class MarionetteTestCase(CommonTestCase):
testvars,
**kwargs
):
- # since we use imp.load_source to load test modules, if a module
- # is loaded with the same name as another one the module would just be
- # reloaded.
+ # since load_source caches modules, if a module is loaded with the same
+ # name as another one the module would just be reloaded.
#
- # We may end up by finding too many test in a module then since
- # reload() only update the module dict (so old keys are still there!)
- # see https://docs.python.org/2/library/functions.html#reload
+ # We may end up by finding too many test in a module then since reload()
+ # only update the module dict (so old keys are still there!) see
+ # https://docs.python.org/2/library/functions.html#reload
#
- # we get rid of that by removing the module from sys.modules,
- # so we ensure that it will be fully loaded by the
- # imp.load_source call.
+ # we get rid of that by removing the module from sys.modules, so we
+ # ensure that it will be fully loaded by the imp.load_source call.
+
if mod_name in sys.modules:
del sys.modules[mod_name]
- test_mod = imp.load_source(mod_name, filepath)
+ test_mod = load_source(mod_name, filepath)
for name in dir(test_mod):
obj = getattr(test_mod, name)
diff --git a/testing/mochitest/mach_commands.py b/testing/mochitest/mach_commands.py
index c1f0c0cfa9..74730a98bd 100644
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -14,6 +14,7 @@ import six
from mach.decorators import Command, CommandArgument
from mozbuild.base import MachCommandConditions as conditions
from mozbuild.base import MozbuildObject
+from mozfile import load_source
here = os.path.abspath(os.path.dirname(__file__))
@@ -90,11 +91,8 @@ class MochitestRunner(MozbuildObject):
"""Runs a mochitest."""
# runtests.py is ambiguous, so we load the file/module manually.
if "mochitest" not in sys.modules:
- import imp
-
path = os.path.join(self.mochitest_dir, "runtests.py")
- with open(path, "r") as fh:
- imp.load_module("mochitest", fh, path, (".py", "r", imp.PY_SOURCE))
+ load_source("mochitest", path)
import mochitest
@@ -145,11 +143,9 @@ class MochitestRunner(MozbuildObject):
if host_ret != 0:
return host_ret
- import imp
-
path = os.path.join(self.mochitest_dir, "runtestsremote.py")
- with open(path, "r") as fh:
- imp.load_module("runtestsremote", fh, path, (".py", "r", imp.PY_SOURCE))
+ load_source("runtestsremote", path)
+
import runtestsremote
options = Namespace(**kwargs)
@@ -195,14 +191,11 @@ def setup_argument_parser():
with warnings.catch_warnings():
warnings.simplefilter("ignore")
- import imp
-
path = os.path.join(build_obj.topobjdir, mochitest_dir, "runtests.py")
if not os.path.exists(path):
path = os.path.join(here, "runtests.py")
- with open(path, "r") as fh:
- imp.load_module("mochitest", fh, path, (".py", "r", imp.PY_SOURCE))
+ load_source("mochitest", path)
from mochitest_options import MochitestArgumentParser
@@ -237,14 +230,11 @@ def setup_junit_argument_parser():
warnings.simplefilter("ignore")
# runtests.py contains MochitestDesktop, required by runjunit
- import imp
-
path = os.path.join(build_obj.topobjdir, mochitest_dir, "runtests.py")
if not os.path.exists(path):
path = os.path.join(here, "runtests.py")
- with open(path, "r") as fh:
- imp.load_module("mochitest", fh, path, (".py", "r", imp.PY_SOURCE))
+ load_source("mochitest", path)
import runjunit
from mozrunner.devices.android_device import (
diff --git a/testing/mozbase/mozfile/mozfile/mozfile.py b/testing/mozbase/mozfile/mozfile/mozfile.py
index 1f4ffa74af..20d56fe4b2 100644
--- a/testing/mozbase/mozfile/mozfile/mozfile.py
+++ b/testing/mozbase/mozfile/mozfile/mozfile.py
@@ -22,6 +22,7 @@ __all__ = [
"extract",
"is_url",
"load",
+ "load_source",
"copy_contents",
"match",
"move",
@@ -629,6 +630,19 @@ def load(resource):
return urllib.request.urlopen(resource)
+# see https://docs.python.org/3/whatsnew/3.12.html#imp
+def load_source(modname, filename):
+ import importlib.machinery
+ import importlib.util
+
+ loader = importlib.machinery.SourceFileLoader(modname, filename)
+ spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
+ module = importlib.util.module_from_spec(spec)
+ sys.modules[module.__name__] = module
+ loader.exec_module(module)
+ return module
+
+
# We can't depend on mozpack.path here, so copy the 'match' function over.
re_cache = {}
diff --git a/testing/mozbase/mozprofile/mozprofile/prefs.py b/testing/mozbase/mozprofile/mozprofile/prefs.py
index 6c3b1173c8..b84d531f23 100644
--- a/testing/mozbase/mozprofile/mozprofile/prefs.py
+++ b/testing/mozbase/mozprofile/mozprofile/prefs.py
@@ -12,7 +12,15 @@ import tokenize
import mozfile
import six
from six import StringIO, string_types
-from six.moves.configparser import SafeConfigParser as ConfigParser
+
+try:
+ from six.moves.configparser import SafeConfigParser as ConfigParser
+except ImportError: # SafeConfigParser was removed in 3.12
+ from configparser import ConfigParser
+try:
+ ConfigParser.read_file
+except AttributeError: # read_file was added in 3.2, readfp removed in 3.12
+ ConfigParser.read_file = ConfigParser.readfp
if six.PY3:
@@ -24,7 +32,7 @@ __all__ = ("PreferencesReadError", "Preferences")
class PreferencesReadError(Exception):
- """read error for prefrences files"""
+ """read error for preferences files"""
class Preferences(object):
@@ -124,7 +132,7 @@ class Preferences(object):
parser = ConfigParser()
parser.optionxform = str
- parser.readfp(mozfile.load(path))
+ parser.read_file(mozfile.load(path))
if section:
if section not in parser.sections():
diff --git a/testing/mozharness/scripts/desktop_unittest.py b/testing/mozharness/scripts/desktop_unittest.py
index 336f2c752b..b2bf44c2b2 100755
--- a/testing/mozharness/scripts/desktop_unittest.py
+++ b/testing/mozharness/scripts/desktop_unittest.py
@@ -12,7 +12,6 @@ author: Jordan Lund
import copy
import glob
-import imp
import json
import multiprocessing
import os
@@ -25,6 +24,7 @@ from datetime import datetime, timedelta
here = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(1, os.path.dirname(here))
+from mozfile import load_source
from mozharness.base.errors import BaseErrorList
from mozharness.base.log import INFO, WARNING
from mozharness.base.script import PreScriptAction
@@ -1167,7 +1167,7 @@ class DesktopUnittest(TestingMixin, MercurialScript, MozbaseMixin, CodeCoverageM
)
if suite_category == "reftest":
- ref_formatter = imp.load_source(
+ ref_formatter = load_source(
"ReftestFormatter",
os.path.abspath(
os.path.join(dirs["abs_reftest_dir"], "output.py")
diff --git a/testing/raptor/mach_commands.py b/testing/raptor/mach_commands.py
index bb9e6b73f5..c076bbbf79 100644
--- a/testing/raptor/mach_commands.py
+++ b/testing/raptor/mach_commands.py
@@ -269,10 +269,10 @@ class RaptorRunner(MozbuildObject):
def setup_node(command_context):
"""Fetch the latest node-16 binary and install it into the .mozbuild directory."""
import platform
- from distutils.version import StrictVersion
from mozbuild.artifact_commands import artifact_toolchain
from mozbuild.nodeutil import find_node_executable
+ from packaging.version import Version
print("Setting up node for browsertime...")
state_dir = get_state_dir()
@@ -280,7 +280,7 @@ def setup_node(command_context):
def __check_for_node():
# Check standard locations first
- node_exe = find_node_executable(min_version=StrictVersion("16.0.0"))
+ node_exe = find_node_executable(min_version=Version("16.0.0"))
if node_exe and (node_exe[0] is not None):
return node_exe[0]
if not os.path.exists(cache_path):
diff --git a/testing/web-platform/manifestupdate.py b/testing/web-platform/manifestupdate.py
index 79b7f1ae56..f8f9d08cb9 100644
--- a/testing/web-platform/manifestupdate.py
+++ b/testing/web-platform/manifestupdate.py
@@ -5,13 +5,13 @@
import argparse
import errno
import hashlib
-import imp
import os
import sys
import manifestdownload
import six
from mach.util import get_state_dir
+from mozfile import load_source
from mozlog.structured import commandline
from six.moves import configparser
from wptrunner import wptcommandline
@@ -21,9 +21,7 @@ manifest = None
def do_delayed_imports(wpt_dir):
global manifest
- imp.load_source(
- "localpaths", os.path.join(wpt_dir, "tests", "tools", "localpaths.py")
- )
+ load_source("localpaths", os.path.join(wpt_dir, "tests", "tools", "localpaths.py"))
sys.path.insert(0, os.path.join(wpt_dir, "tools", "manifest"))
import manifest
diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/scope1/redirect.py b/testing/web-platform/tests/service-workers/service-worker/resources/scope1/redirect.py
index bb4c874aac..025ea671c5 100644
--- a/testing/web-platform/tests/service-workers/service-worker/resources/scope1/redirect.py
+++ b/testing/web-platform/tests/service-workers/service-worker/resources/scope1/redirect.py
@@ -1,6 +1,8 @@
import os
-import imp
+
+from tools.wpt.utils import load_source
+
# Use the file from the parent directory.
-mod = imp.load_source("_parent", os.path.join(os.path.dirname(os.path.dirname(__file__)),
+mod = load_source("_parent", os.path.join(os.path.dirname(os.path.dirname(__file__)),
os.path.basename(__file__)))
main = mod.main
diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/scope2/worker_interception_redirect_webworker.py b/testing/web-platform/tests/service-workers/service-worker/resources/scope2/worker_interception_redirect_webworker.py
index bb4c874aac..025ea671c5 100644
--- a/testing/web-platform/tests/service-workers/service-worker/resources/scope2/worker_interception_redirect_webworker.py
+++ b/testing/web-platform/tests/service-workers/service-worker/resources/scope2/worker_interception_redirect_webworker.py
@@ -1,6 +1,8 @@
import os
-import imp
+
+from tools.wpt.utils import load_source
+
# Use the file from the parent directory.
-mod = imp.load_source("_parent", os.path.join(os.path.dirname(os.path.dirname(__file__)),
+mod = load_source("_parent", os.path.join(os.path.dirname(os.path.dirname(__file__)),
os.path.basename(__file__)))
main = mod.main
diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/subdir/worker_interception_redirect_webworker.py b/testing/web-platform/tests/service-workers/service-worker/resources/subdir/worker_interception_redirect_webworker.py
index bb4c874aac..025ea671c5 100644
--- a/testing/web-platform/tests/service-workers/service-worker/resources/subdir/worker_interception_redirect_webworker.py
+++ b/testing/web-platform/tests/service-workers/service-worker/resources/subdir/worker_interception_redirect_webworker.py
@@ -1,6 +1,8 @@
import os
-import imp
+
+from tools.wpt.utils import load_source
+
# Use the file from the parent directory.
-mod = imp.load_source("_parent", os.path.join(os.path.dirname(os.path.dirname(__file__)),
+mod = load_source("_parent", os.path.join(os.path.dirname(os.path.dirname(__file__)),
os.path.basename(__file__)))
main = mod.main
diff --git a/testing/web-platform/tests/tools/runner/update_manifest.py b/testing/web-platform/tests/tools/runner/update_manifest.py
index a7f72b35b3..58b9ac4d84 100644
--- a/testing/web-platform/tests/tools/runner/update_manifest.py
+++ b/testing/web-platform/tests/tools/runner/update_manifest.py
@@ -1,16 +1,18 @@
# mypy: ignore-errors
-import imp
import json
import os
+from tools.wpt.utils import load_source
+
here = os.path.dirname(__file__)
-localpaths = imp.load_source("localpaths", os.path.abspath(os.path.join(here, os.pardir, "localpaths.py")))
+localpaths = load_source("localpaths", os.path.abspath(os.path.join(here, os.pardir, "localpaths.py")))
root = localpaths.repo_root
from manifest import manifest
+
def main(request, response):
path = os.path.join(root, "MANIFEST.json")
diff --git a/testing/web-platform/tests/tools/wpt/utils.py b/testing/web-platform/tests/tools/wpt/utils.py
index b015b95e1a..5899dc3f3a 100644
--- a/testing/web-platform/tests/tools/wpt/utils.py
+++ b/testing/web-platform/tests/tools/wpt/utils.py
@@ -3,10 +3,10 @@
import errno
import logging
import os
-import sys
import shutil
import stat
import subprocess
+import sys
import tarfile
import time
import zipfile
@@ -166,3 +166,16 @@ def sha256sum(file_path):
for chunk in iter(lambda: f.read(4096), b''):
hash.update(chunk)
return hash.hexdigest()
+
+
+# see https://docs.python.org/3/whatsnew/3.12.html#imp
+def load_source(modname, filename):
+ import importlib.machinery
+ import importlib.util
+
+ loader = importlib.machinery.SourceFileLoader(modname, filename)
+ spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
+ module = importlib.util.module_from_spec(spec)
+ sys.modules[module.__name__] = module
+ loader.exec_module(module)
+ return module
diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/stability.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/stability.py
index 9ac6249c44..1f17ef3c47 100644
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/stability.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/stability.py
@@ -2,7 +2,6 @@
import copy
import functools
-import imp
import io
import os
from collections import OrderedDict, defaultdict
@@ -10,16 +9,17 @@ from datetime import datetime
from mozlog import reader
from mozlog.formatters import JSONFormatter
-from mozlog.handlers import BaseHandler, StreamHandler, LogLevelFilter
+from mozlog.handlers import BaseHandler, LogLevelFilter, StreamHandler
+
+from tools.wpt.utils import load_source
from . import wptrunner
here = os.path.dirname(__file__)
-localpaths = imp.load_source("localpaths", os.path.abspath(os.path.join(here, os.pardir, os.pardir, "localpaths.py")))
+localpaths = load_source("localpaths", os.path.abspath(os.path.join(here, os.pardir, os.pardir, "localpaths.py")))
from ci.tc.github_checks_output import get_gh_checks_outputter # type: ignore
from wpt.markdown import markdown_adjust, table # type: ignore
-
# If a test takes more than (FLAKY_THRESHOLD*timeout) and does not consistently
# time out, it is considered slow (potentially flaky).
FLAKY_THRESHOLD = 0.8
diff --git a/testing/web-platform/tests/xhr/resources/auth1/auth.py b/testing/web-platform/tests/xhr/resources/auth1/auth.py
index db4f7bc4c9..3797aaa52e 100644
--- a/testing/web-platform/tests/xhr/resources/auth1/auth.py
+++ b/testing/web-platform/tests/xhr/resources/auth1/auth.py
@@ -1,12 +1,13 @@
-import imp
import os
from wptserve.utils import isomorphic_decode
+from tools.wpt.utils import load_source
+
here = os.path.dirname(os.path.abspath(isomorphic_decode(__file__)))
def main(request, response):
- auth = imp.load_source(u"", os.path.join(here,
+ auth = load_source(u"", os.path.join(here,
u"..",
u"authentication.py"))
return auth.main(request, response)
diff --git a/testing/web-platform/tests/xhr/resources/auth10/auth.py b/testing/web-platform/tests/xhr/resources/auth10/auth.py
index db4f7bc4c9..568d31e906 100644
--- a/testing/web-platform/tests/xhr/resources/auth10/auth.py
+++ b/testing/web-platform/tests/xhr/resources/auth10/auth.py
@@ -1,12 +1,14 @@
-import imp
import os
from wptserve.utils import isomorphic_decode
+from tools.wpt.utils import load_source
+
here = os.path.dirname(os.path.abspath(isomorphic_decode(__file__)))
+
def main(request, response):
- auth = imp.load_source(u"", os.path.join(here,
+ auth = load_source(u"", os.path.join(here,
u"..",
u"authentication.py"))
return auth.main(request, response)
diff --git a/testing/web-platform/tests/xhr/resources/auth11/auth.py b/testing/web-platform/tests/xhr/resources/auth11/auth.py
index db4f7bc4c9..3797aaa52e 100644
--- a/testing/web-platform/tests/xhr/resources/auth11/auth.py
+++ b/testing/web-platform/tests/xhr/resources/auth11/auth.py
@@ -1,12 +1,13 @@
-import imp
import os
from wptserve.utils import isomorphic_decode
+from tools.wpt.utils import load_source
+
here = os.path.dirname(os.path.abspath(isomorphic_decode(__file__)))
def main(request, response):
- auth = imp.load_source(u"", os.path.join(here,
+ auth = load_source(u"", os.path.join(here,
u"..",
u"authentication.py"))
return auth.main(request, response)
diff --git a/testing/web-platform/tests/xhr/resources/auth2/auth.py b/testing/web-platform/tests/xhr/resources/auth2/auth.py
index db4f7bc4c9..568d31e906 100644
--- a/testing/web-platform/tests/xhr/resources/auth2/auth.py
+++ b/testing/web-platform/tests/xhr/resources/auth2/auth.py
@@ -1,12 +1,14 @@
-import imp
import os
from wptserve.utils import isomorphic_decode
+from tools.wpt.utils import load_source
+
here = os.path.dirname(os.path.abspath(isomorphic_decode(__file__)))
+
def main(request, response):
- auth = imp.load_source(u"", os.path.join(here,
+ auth = load_source(u"", os.path.join(here,
u"..",
u"authentication.py"))
return auth.main(request, response)
diff --git a/testing/web-platform/tests/xhr/resources/auth2/corsenabled.py b/testing/web-platform/tests/xhr/resources/auth2/corsenabled.py
index bec6687dbe..7b9d3b65ab 100644
--- a/testing/web-platform/tests/xhr/resources/auth2/corsenabled.py
+++ b/testing/web-platform/tests/xhr/resources/auth2/corsenabled.py
@@ -1,8 +1,9 @@
-import imp
import os
from wptserve.utils import isomorphic_decode
+from tools.wpt.utils import load_source
+
here = os.path.dirname(isomorphic_decode(__file__))
def main(request, response):
@@ -11,7 +12,7 @@ def main(request, response):
response.headers.set(b'Access-Control-Allow-Methods', b'GET')
response.headers.set(b'Access-Control-Allow-Headers', b'authorization, x-user, x-pass')
response.headers.set(b'Access-Control-Expose-Headers', b'x-challenge, xhr-user, ses-user')
- auth = imp.load_source(u"", os.path.abspath(os.path.join(here, os.pardir, u"authentication.py")))
+ auth = load_source(u"", os.path.abspath(os.path.join(here, os.pardir, u"authentication.py")))
if request.method == u"OPTIONS":
return b""
else:
diff --git a/testing/web-platform/tests/xhr/resources/auth3/auth.py b/testing/web-platform/tests/xhr/resources/auth3/auth.py
index db4f7bc4c9..3797aaa52e 100644
--- a/testing/web-platform/tests/xhr/resources/auth3/auth.py
+++ b/testing/web-platform/tests/xhr/resources/auth3/auth.py
@@ -1,12 +1,13 @@
-import imp
import os
from wptserve.utils import isomorphic_decode
+from tools.wpt.utils import load_source
+
here = os.path.dirname(os.path.abspath(isomorphic_decode(__file__)))
def main(request, response):
- auth = imp.load_source(u"", os.path.join(here,
+ auth = load_source(u"", os.path.join(here,
u"..",
u"authentication.py"))
return auth.main(request, response)
diff --git a/testing/web-platform/tests/xhr/resources/auth4/auth.py b/testing/web-platform/tests/xhr/resources/auth4/auth.py
index db4f7bc4c9..3797aaa52e 100644
--- a/testing/web-platform/tests/xhr/resources/auth4/auth.py
+++ b/testing/web-platform/tests/xhr/resources/auth4/auth.py
@@ -1,12 +1,13 @@
-import imp
import os
from wptserve.utils import isomorphic_decode
+from tools.wpt.utils import load_source
+
here = os.path.dirname(os.path.abspath(isomorphic_decode(__file__)))
def main(request, response):
- auth = imp.load_source(u"", os.path.join(here,
+ auth = load_source(u"", os.path.join(here,
u"..",
u"authentication.py"))
return auth.main(request, response)
diff --git a/testing/web-platform/tests/xhr/resources/auth7/corsenabled.py b/testing/web-platform/tests/xhr/resources/auth7/corsenabled.py
index 7a060627b7..c82ba4e6bc 100644
--- a/testing/web-platform/tests/xhr/resources/auth7/corsenabled.py
+++ b/testing/web-platform/tests/xhr/resources/auth7/corsenabled.py
@@ -1,8 +1,9 @@
-import imp
import os
from wptserve.utils import isomorphic_decode
+from tools.wpt.utils import load_source
+
here = os.path.dirname(isomorphic_decode(__file__))
def main(request, response):
@@ -11,7 +12,7 @@ def main(request, response):
response.headers.set(b'Access-Control-Allow-Methods', b'GET')
response.headers.set(b'Access-Control-Allow-Headers', b'authorization, x-user, x-pass')
response.headers.set(b'Access-Control-Expose-Headers', b'x-challenge, xhr-user, ses-user')
- auth = imp.load_source(u"", os.path.join(here,
+ auth = load_source(u"", os.path.join(here,
os.pardir,
u"authentication.py"))
if request.method == u"OPTIONS":
diff --git a/testing/web-platform/tests/xhr/resources/auth8/corsenabled-no-authorize.py b/testing/web-platform/tests/xhr/resources/auth8/corsenabled-no-authorize.py
index af8e7c4c17..4fdf99e265 100644
--- a/testing/web-platform/tests/xhr/resources/auth8/corsenabled-no-authorize.py
+++ b/testing/web-platform/tests/xhr/resources/auth8/corsenabled-no-authorize.py
@@ -1,8 +1,9 @@
-import imp
import os
from wptserve.utils import isomorphic_decode
+from tools.wpt.utils import load_source
+
here = os.path.dirname(isomorphic_decode(__file__))
def main(request, response):
@@ -11,7 +12,7 @@ def main(request, response):
response.headers.set(b'Access-Control-Allow-Methods', b'GET')
response.headers.set(b'Access-Control-Allow-Headers', b'x-user, x-pass')
response.headers.set(b'Access-Control-Expose-Headers', b'x-challenge, xhr-user, ses-user')
- auth = imp.load_source(u"", os.path.join(here,
+ auth = load_source(u"", os.path.join(here,
os.pardir,
u"authentication.py"))
if request.method == u"OPTIONS":
diff --git a/testing/web-platform/tests/xhr/resources/auth9/auth.py b/testing/web-platform/tests/xhr/resources/auth9/auth.py
index db4f7bc4c9..3797aaa52e 100644
--- a/testing/web-platform/tests/xhr/resources/auth9/auth.py
+++ b/testing/web-platform/tests/xhr/resources/auth9/auth.py
@@ -1,12 +1,13 @@
-import imp
import os
from wptserve.utils import isomorphic_decode
+from tools.wpt.utils import load_source
+
here = os.path.dirname(os.path.abspath(isomorphic_decode(__file__)))
def main(request, response):
- auth = imp.load_source(u"", os.path.join(here,
+ auth = load_source(u"", os.path.join(here,
u"..",
u"authentication.py"))
return auth.main(request, response)
diff --git a/testing/web-platform/update/__init__.py b/testing/web-platform/update/__init__.py
index 47c6d36d95..66bb6f2ab6 100644
--- a/testing/web-platform/update/__init__.py
+++ b/testing/web-platform/update/__init__.py
@@ -4,15 +4,15 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-import imp
import os
import sys
+from mozfile import load_source
from mozlog import structuredlog
here = os.path.split(__file__)[0]
-imp.load_source(
+load_source(
"localpaths", os.path.join(here, os.pardir, "tests", "tools", "localpaths.py")
)