From f3bcaf9f88aad2c423ebcd61121562f9834187d4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 8 Apr 2024 17:11:27 +0200 Subject: Merging upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- .../marionette_test/testcases.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'testing/marionette/harness') 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) -- cgit v1.2.3