From ece16ca7ef8201d867ba662d90665b9597ed5de2 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 15 Apr 2024 16:24:38 +0100 Subject: [PATCH] Revert "Add tests for opts dunder" This reverts commit 54372bd24803a1e49d8e1ea4cf1cb6d3273d4590. --- salt/loader/dunder.py | 1 - .../pytests/functional/loader/test_dunder.py | 49 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 tests/pytests/functional/loader/test_dunder.py diff --git a/salt/loader/dunder.py b/salt/loader/dunder.py index 3b198b1497f..321e6f9a69d 100644 --- a/salt/loader/dunder.py +++ b/salt/loader/dunder.py @@ -8,7 +8,6 @@ loader_context = salt.loader.context.LoaderContext() __file_client__ = loader_context.named_context("__file_client__", default=None) -__opts__ = loader_context.named_context("__opts__") __context__ = loader_context.named_context("__context__") __pillar__ = loader_context.named_context("__pillar__") __grains__ = loader_context.named_context("__grains__") diff --git a/tests/pytests/functional/loader/test_dunder.py b/tests/pytests/functional/loader/test_dunder.py deleted file mode 100644 index 4cd0d629cdc..00000000000 --- a/tests/pytests/functional/loader/test_dunder.py +++ /dev/null @@ -1,49 +0,0 @@ -import pathlib - -import salt.loader.context -import salt.loader.lazy -import salt.utils.files -import tests.support.helpers - - -def test_opts_dunder_opts_without_import(tempdir): - """ - Test __opts__ without being imported. - - When a loaded module uses __opts__ but does not import it from - salt.loader.dunder the __opts__ object will be a dictionary. - """ - opts = {"optimization_order": [0, 1, 2]} - with salt.utils.files.fopen(pathlib.Path(tempdir.tempdir) / "mymod.py", "w") as fp: - fp.write( - tests.support.helpers.dedent( - """ - def mymethod(): - return type(__opts__) - """ - ) - ) - loader = salt.loader.lazy.LazyLoader([tempdir.tempdir], opts) - assert loader["mymod.mymethod"]() == dict - - -def test_opts_dunder_opts_with_import(tempdir): - """ - Test __opts__ when imported. - - When a loaded module uses __opts__ by importing it from - salt.loader.dunder the __opts__ object will be a NamedLoaderContext. - """ - opts = {"optimization_order": [0, 1, 2]} - with salt.utils.files.fopen(pathlib.Path(tempdir.tempdir) / "mymod.py", "w") as fp: - fp.write( - tests.support.helpers.dedent( - """ - from salt.loader.dunder import __opts__ - def mymethod(): - return type(__opts__) - """ - ) - ) - loader = salt.loader.lazy.LazyLoader([tempdir.tempdir], opts) - assert loader["mymod.mymethod"]() == salt.loader.context.NamedLoaderContext